I'm using the following NestInterceptor to add code, message and data to final response:
export class HttpResponseInterceptor implements NestInterceptor {
intercept(context: ExecutionContext, next: CallHandler): Observable<any> {
return next.handle().pipe(map(data => ({
code: 200,
message: 'ok',
data: data
}))
);
}
}
The result I expected:
{
"code": 200,
"message: "ok",
"data": {
"vip": 333,
"enterprise": 14,
"pension": 712
}
}
The result I'm getting:
{
"code": 200,
"message": "ok",
"data": "{\"vip\":333,\"enterprise\":14,\"pension\":712}"}
I don't want auto stringify data, what should I do?
Update: Removing GlobalFilters
won't work, I only have HttpResponseInterceptor
as the GlobalInterceptors
It was determined this came from Nestia's
TypedRoute
feature. Currently it looks like the only way around it is to not use the TypedRoute