Interceptors — Basics · NestJS

Wrap handlers with interceptors: name the handler in a response header on the way in, and map every response body into an envelope on the way out.

What you will learn

Read the theory for Interceptors

All Basics lessons

All NestJS courses

loading types…

What you'll learn

  • Implement NestInterceptor and use the ExecutionContext to name the handler and set a response header before it runs
  • Transform response bodies with the map operator, and explain why a thrown exception is not mapped
  • Bind interceptors to a controller with @UseInterceptors and to the application with useGlobalInterceptors