dto对象
This commit is contained in:
parent
aea8856148
commit
34ea934195
|
@ -0,0 +1,3 @@
|
|||
export class CreatePostDto {
|
||||
readonly title: string
|
||||
}
|
|
@ -1,4 +1,5 @@
|
|||
import { Controller, Get, Post, Req, Query, Headers, Param, Body } from '@nestjs/common';
|
||||
import { CreatePostDto } from './post.dto';
|
||||
|
||||
@Controller('posts')
|
||||
export class PostsController {
|
||||
|
@ -21,8 +22,8 @@ export class PostsController {
|
|||
}
|
||||
|
||||
@Post()
|
||||
store(@Body() body) {
|
||||
console.log(body)
|
||||
return body
|
||||
store(@Body() post: CreatePostDto) {
|
||||
console.log(post)
|
||||
return post
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue