NestJS · Middle · Question 7 of 75
How can an interceptor wrap every response in { data: ... }?
- 1By changing every controller
- 2With a pipe on the response
- ✓Correct answer:
return next.handle().pipe(map((data) => ({ data })))
Explanation
Interceptors are the place for cross-cutting response changes. Be consistent: errors are shaped by exception filters, not interceptors.