serialize a bigint Plugins

2024-09-03 11:22:15 - FATAL - TypeError: Do not know how to serialize a BigInt
2024-09-03 11:22:15 - FATAL - at JSON.stringify (<anonymous>)
2024-09-03 11:22:15 - FATAL - at _ApiResponse.json (/home/x/SwBot/node_modules/@sapphire/plugin-api/dist/cjs/lib/structures/api/ApiResponse.cjs:101:75)
2024-09-03 11:22:15 - FATAL - at [HTTP-GET] (/home/x/SwBot/dist/routes/answers.js:20:25)
2024-09-03 11:22:15 - FATAL - at async _PluginListener.run (/home/x/SwBot/node_modules/@sapphire/plugin-api/dist/cjs/listeners/PluginServerMiddlewareSuccess.cjs:14:7)
2024-09-03 11:22:15 - FATAL - at async Object.fromAsync (/home/x/SwBot/node_modules/@sapphire/result/dist/cjs/index.cjs:619:22)
2024-09-03 11:22:15 - FATAL - at async _PluginListener._run (/home/xn/SwBot/node_modules/@sapphire/framework/dist/cjs/lib/structures/Listener.cjs:27:22)
2024-09-03 11:22:15 - FATAL - TypeError: Do not know how to serialize a BigInt
2024-09-03 11:22:15 - FATAL - at JSON.stringify (<anonymous>)
2024-09-03 11:22:15 - FATAL - at _ApiResponse.json (/home/x/SwBot/node_modules/@sapphire/plugin-api/dist/cjs/lib/structures/api/ApiResponse.cjs:101:75)
2024-09-03 11:22:15 - FATAL - at [HTTP-GET] (/home/x/SwBot/dist/routes/answers.js:20:25)
2024-09-03 11:22:15 - FATAL - at async _PluginListener.run (/home/x/SwBot/node_modules/@sapphire/plugin-api/dist/cjs/listeners/PluginServerMiddlewareSuccess.cjs:14:7)
2024-09-03 11:22:15 - FATAL - at async Object.fromAsync (/home/x/SwBot/node_modules/@sapphire/result/dist/cjs/index.cjs:619:22)
2024-09-03 11:22:15 - FATAL - at async _PluginListener._run (/home/xn/SwBot/node_modules/@sapphire/framework/dist/cjs/lib/structures/Listener.cjs:27:22)
5 Replies
Favna
Favna2mo ago
@kyra 🩵🩷🤍🩷🩵 is this fixed with the rewrites?
kyra
kyra2mo ago
It’s a separate path, can be solved by making the object they’re serialising have a toJSON method Otherwise I can “fix it” by serialising bigint to string but… that has a heavy performance impact
čamdžić
čamdžić2mo ago
how can I fix this i just put a Date.now() as BigInt in prisma and return that in res.json
Favna
Favna2mo ago
If it's a date, maybe serialize it to a string beforehand? Unix timestamp as a string that is.
kyra
kyra2mo ago
Number is fine in that specific case
Want results from more Discord servers?
Add your server