我正在尝试实现this示例。它看起来实现起来很简单,但是我遇到了一些麻烦。
@Get('test')
async test(
@Query('size', new DefaultValuePipe(10), ParseIntPipe) size: number,
@Query('page', new DefaultValuePipe(1), ParseIntPipe) page: number,
) {
// Do some stuff
}
http://localhost/api/test
400 Bad Request
,消息为Validation failed (numeric string is expected)
。http://localhost/api/test?size=&page=
0
的形式传递,而不是默认情况下要提供的值。在两个请求中,默认值都希望通过,对吗?如果是这样,我在做什么错了?