【发布时间】:2021-05-13 06:26:34
【问题描述】:
您好,我有 Nest 应用程序 dto:
export class TestDto {
@IsNotEmpty()
id: number;
@IsNotEmpty()
slug: string;
@IsNotEmpty()
size: number;
}
和发布请求:
@Post(':id/start')
async startTest(
@Param('id') id: number,
@Request() req,
@Body() testDto?: TestDto
): Promise<RoomDto | string> {
return await this.roomsService.startTest(id, testDto);
}
我想从 body 中选择 testDto,但发送请求时出现错误:
{
"statusCode": 400,
"message": [
"slug should not be empty",
"size should not be empty"
],
"error": "Bad Request"
}
如何实现这样的目标?
【问题讨论】:
标签: javascript nestjs