Bird
0
0

In NestJS, which decorator is used in a controller method to handle HTTP POST requests for creating data?

easy📝 Conceptual Q11 of 15
NestJS - Database with TypeORM
In NestJS, which decorator is used in a controller method to handle HTTP POST requests for creating data?
A@Post
B@Get
C@Put
D@Delete
Step-by-Step Solution
Solution:
  1. Step 1: Understand HTTP methods and their NestJS decorators

    HTTP POST is used to create new data. NestJS uses @Post decorator for this.
  2. Step 2: Match the decorator to the HTTP method

    @Get is for reading, @Put for updating, and @Delete for deleting data, so they don't fit creating data.
  3. Final Answer:

    @Post -> Option A
  4. Quick Check:

    POST = @Post [OK]
Quick Trick: POST requests use @Post decorator in NestJS controllers [OK]
Common Mistakes:
  • Confusing @Get with @Post
  • Using @Put for creating data
  • Using @Delete for creation

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More NestJS Quizzes