NestJS从数组匹配中获取参数

时间:2019-11-16 17:18:17

标签: nestjs

我不知道如何从该定义中获取匹配的参数:

@Get(['FAVORITE', 'RATING', 'FAVORITE_AND_RATING'])
find(...): Promise<Array<any>> {
    /// how to get param what was matched
}

1 个答案:

答案 0 :(得分:0)

这可能只是一种解决方法,但它应该可以工作

@Get(['FAVORITE', 'RATING', 'FAVORITE_AND_RATING'])
find(@Param('FAVORITE') favorite: string, @Param('RATING') rating: string, 
     @Param('FAVORITE_AND_RATING') favorite_and_rating: string): Promise<Array<any>> {
    if(favorite) {
      //stuff to do
    } else if(rating) {
      //stuff to do
    } else if(favorite_and_rating) {
      //stuff to do
    }
}