发现原因是@UseGuards使用错误,不要使用2个@UseGuards装饰器,而是像下面这样使用才正确。
@UseGuards(JwtAuthGuard, RoleGuard)
@Post()
create(@Body() createCategoryDto: CreateCategoryDto) {
return this.categoriesService.create(createCategoryDto);
}
发现原因是@UseGuards使用错误,不要使用2个@UseGuards装饰器,而是像下面这样使用才正确。
@UseGuards(JwtAuthGuard, RoleGuard)
@Post()
create(@Body() createCategoryDto: CreateCategoryDto) {
return this.categoriesService.create(createCategoryDto);
}