@Controller('users') exportclass UserController { @Get('/:id') getOne(@Param('id') userId: string) { return`This will return one user with the id: ${userId}`; } }
@Body
Body는 JSON 형식으로 받아올 때 사용합니다.
1 2 3 4 5
// NestJS @Body(param?: string)
// ExpressJS req.body / req.body[param]
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
import { Body, Controller, Param, Patch, Post } from'@nestjs/common';
@Controller('users') exportclass UserController { @Get('search') search(@Query('id') userId: string) { return`We are searching for a user made after: ${userId}`; } }