Reputation: 57
Where is the object that references the @body payload stored?
If your user controller has a post function.
@Post() @HttpCode(HttpStatus.CREATED) create(@Body() user: IUserBase): Promise { return this.usersService.create(user); }
Where is the user variable stored? Is it stored in the request object of the nest.js server?
Upvotes: 2
Views: 3575
Reputation: 1813
It is injected into the function as an argument.
The @body
decorator basically says:
Please cast the json that arrives in the request body into IUserBase
type and place it as a parameter to this controller's handler.
Upvotes: 3