与无服务器一起使用时,NestJs Body()未填充请求信息

时间:2019-04-24 11:01:18

标签: serverless nestjs

在脱机运行SLS或SLS时,不会通过传递的对象填充在nest中部署主体装饰器。

我已经组织了一个小型仓库来对有兴趣的人进行调查。

https://gitlab.com/claridgicus/nest-serverless-body-issue

SLS离线输出

[Nest] 91880   - 2019-04-24 20:58   [ExceptionHandler] Map#toJSON isn't generic +5ms
TypeError: Map#toJSON isn't generic
    at String.toJSON (c:\Users\Claridgicus\AppData\Roaming\npm\node_modules\serverless\node_modules\core-js\modules\_collection-to-json.js:6:38)
    at Function.<anonymous> (c:\Users\Claridgicus\AppData\Roaming\npm\node_modules\serverless\node_modules\core-js\modules\_ctx.js:18:15)
    at JSON.stringify (<anonymous>)
    at Function.stringify [as default] (c:\Users\Claridgicus\code\serverless-nestjs-master\node_modules\fast-safe-stringify\index.js:11:18)
    at ModuleTokenFactory.getDynamicMetadataToken (c:\Users\Claridgicus\code\serverless-nestjs-master\node_modules\@nestjs\core\injector\module-token-factory.js:20:69)
    at ModuleTokenFactory.create (c:\Users\Claridgicus\code\serverless-nestjs-master\node_modules\@nestjs\core\injector\module-token-factory.js:12:27)
    at ModuleCompiler.compile (c:\Users\Claridgicus\code\serverless-nestjs-master\node_modules\@nestjs\core\injector\compiler.js:19:47)
    at <anonymous>
    at process._tickDomainCallback (internal/process/next_tick.js:228:7)
 1: std::vector<v8::CpuProfileDeoptFrame,std::allocator<v8::CpuProfileDeoptFrame> >::vector<v8::CpuProfileDeoptFrame,std::allocator<v8::CpuProfileDeoptFrame> >
 2: v8::internal::wasm::SignatureMap::Find
 3: v8::internal::Builtins::CallableFor
 4: v8::internal::Builtins::CallableFor
 5: v8::internal::Builtins::CallableFor
 6: 0000006B886843C1

1 个答案:

答案 0 :(得分:0)

所以

经过一番摸索-我再次检查了传入请求中的标头

关于来自联储的传入POST请求-仔细检查您正在设置标头-并节省了与我不同的几个小时:)

    headers: {
        "Content-Type": "application/json"
    },