问题描述
在我正在从事的项目中,规范指出请求主体将具有 bigints 文字而不是字符串,例如:
{
total_supply: 96585829199248589999910000000000000000000
}
我的 DTO 更改为:
total_supply?: bigint
当然,我预计第一次尝试会失败,因为默认的 JSON.stringify
不会处理这些 bigint:
TypeError: Do not kNow how to serialize a BigInt
at JSON.stringify (<anonymous>)
at new Request (../node_modules/light-my-request/lib/request.js:98:20)
at ../node_modules/light-my-request/index.js:110:19
at doInject (../node_modules/light-my-request/index.js:109:12)
at Chain.<computed> [as then] (../node_modules/light-my-request/index.js:199:23)
如何在 nestJS 中用适当的例程(例如:https://www.npmjs.com/package/@randlabs/json-bigint)替换 JSON 处理例程?也许使用拦截器?如果可能的话,我想以“nestJS 方式”进行。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)