frankind.eth | Franco Aguzzi
How to retrieve and receive Bigint data to/from TRPC procedure
Hi @NEO
I've added something very similar (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt#use_within_json) to the code snippet you've shared and the issue was fixed! 🥳
Thanks so much for your help @nlucas and @NEO, I really appreciate it!
11 replies
How to retrieve and receive Bigint data to/from TRPC procedure
I've extracted the registration of this custom type to a file which is being imported in both client and server TRPC configuration files, but the error below persists:
TypeError: Do not know how to serialize a BigInt
I wonder if this is related to TRPC procedures config, to SuperJson lib (which should give support to BigInt without the need of registering new custom serialize/deserialize function for it, as mentioned in their docs: https://github.com/blitz-js/superjson#examples-3) or to Next.js
Neither SuperJson, TRPC nor Next.js Github issues contain related issues, so I'm finding myself completely stuck in this limitation now 😮💨
11 replies
How to retrieve and receive Bigint data to/from TRPC procedure
@Nick Lucas
Adding the following code wasn't enough for getting rid of the error:
TypeError: Do not know how to serialize a BigInt
registerCustom<bigint, string>(
{
isApplicable: (v): v is bigint => typeof v === "bigint",
serialize: (v) => v.toString(),
deserialize: (v) => BigInt(v),
},
"bigint",
);
Do you have any other suggestion on how to fix this issue?
I'm send attached to this message my TRPC server file + TRPC client file so you can have more visibility of how I'm implementing things here 👍
11 replies