NestJS · Junior · Question 17 of 75
How do you read the JSON body of a POST request in a controller?
- ✓Correct answer: With the
@Body()parameter decorator, usually typed with a DTO class - 2With
@Param() - 3With
req.json()only
Explanation
@Body() dto: CreateUserDto. @Query() reads query strings, @Param() route params, @Headers() headers.