CodePark/ questions / Controllers & routing
START PRACTICINGPRACTICE
Backend question · NestJS › Controllers & routing

With no @HttpCode() decorator, what status codes does Nest send for a successful @Post() handler and a successful @Get() handler?

201 and 200

POST sends 201 and GET sends 200. Nest's default success status is 200 for every method except POST, which defaults to 201 (Created). You change it per handler with @HttpCode(204) or another code.

"201 and 204" is wrong. Nest never switches to 204 on its own just because the handler returns nothing.