Controllers — Basics · NestJS

Read route and query parameters, accept a JSON body, await an async service, and override the status code Nest picks for a POST.

What you will learn

Read the theory for Controllers

All Basics lessons

All NestJS courses

loading types…

What you'll learn

  • Declare routes whose paths compose from the controller prefix and the method path
  • Read route parameters, the query string and the JSON body with parameter decorators, and treat them as the strings they are
  • Write an async handler that awaits a service, and override a POST's default 201 with @HttpCode()