params.ts에 담아뒀던 파일(dto도 가능)에 다음과 같이 정의를 했었다.
해결 전
export class CompanyRequestParams extends CollectionAddressOrSlugParams {
@IsNumber()
@IsOptional()
readonly tokenId: number;
...
}
Run을 해보니 must be a number conforming to the specified constraints 라는 400 에러가 떴다.
number Type에 대해 뭔가 문제가 있는걸까 싶어서 구글링을 해보니 type 변환의 문제였으며 @Type 데코레이터로 Number로 type을 변환해줘야 했다.
해결 후
export class CompanyRequestParams extends CollectionAddressOrSlugParams {
@Type(() => Number)
@IsNumber()
@IsOptioanl()
readonly tokenId: number;
...
}
그랬더니 조회가 잘 되었다.
'Backend > NestJS' 카테고리의 다른 글
If BenefitTxHistoryRepository is a provider, is it part of the current AdminApiModule? (0) | 2023.10.26 |
---|---|
param.ts 파일이나 dto에서 다른 파일에서 쓰여진 Enum 끌고오기 (0) | 2023.10.17 |
keyof와 typeof (1) | 2023.10.17 |
다른 api 호출해오는법 (feat. httpService) (0) | 2023.10.17 |
api.module.ts에서 global:true로 넣기 (0) | 2023.09.20 |