class-transform 执行两次 debug

class-transform 执行两次 debug
John Doeclass-transform 执行两次 debug
没有什么技术含量, 只是记录一下过程。
具体问题在这里
[nestjs
- class-transfrom @Transform execute twice and return null -
Stack Overflow](https://stackoverflow.com/questions/75673361/class-transfrom-transform-execute-twice-and-return-null)
1. vscode debug
在这里打一个断点, vscode attach端口。请求对应接口。 vscode
会自动中断于断点处
调试
查看调用堆栈。 发现被调用了两次 class-transfrom。 第二次调用的时候是
nest 调用的, 但是nest 并没有依赖
class-transfrom。所以就想到了是不是做了一层全局的序列化。 到main.ts
里面找到了相关代码。 去掉全局序列化就行了。
1 | app.useGlobalInterceptors(new ClassSerializerInterceptor(app.get(Reflector))); |









