Skip to content

Add support for BigInt #474

@bitbytebit1

Description

@bitbytebit1

Describe the feature

Currently if a BigInt needs to be sent to the client an error will be thrown.

[nuxt] [request error] [unhandled] [500] Do not know how to serialize a BigInt                                                                     1:31:58 PM
  at JSON.stringify (<anonymous>)  
  at Object.handler (./node_modules/h3/dist/index.mjs:1304:18)  
  at processTicksAndRejections (node:internal/process/task_queues:96:5)  
  at async toNodeHandle (./node_modules/h3/dist/index.mjs:1359:7)  
  at async ufetch (./node_modules/unenv/runtime/fetch/index.mjs:9:17)  
  at async $fetchRaw2 (./node_modules/ofetch/dist/shared/ofetch.d438bb6f.mjs:206:26)  
  at async $fetch2 (./node_modules/ofetch/dist/shared/ofetch.d438bb6f.mjs:239:15)  

Would love to see support for this!

One possible solution would be to use the reviver function. However I understand this would add complexity to both the sever and client. Wondering what the teams thoughts are regarding this functionality?

https://stackoverflow.com/questions/62539236/how-to-parse-a-json-data-type-bigint-in-typescript

Additional information

  • Would you be willing to help implement this feature?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions