아래의 내용으로 아무리 해도 안 되어서 그냥 :artist-id를 :artistId로 수정(통일)했더니 해결됐다.
Param 값과 Route에서 설정한 파라미터 값 일치하지 않을 때 undefined 에러 발생
[ExceptionsHandler] QueryFailedError: Unknown column 'undefined' in 'where clause'
SELECT * FROM artist WHERE id = undefined
잘못된 코드
@Get(':artist-id')
async artistAll(@Param('aritstId') artistId: number) {
올바른 코드
@Get(':artist-id')
async artistAll(@Param('artist-id') artistIdStr: string) {
const artistId = Number(artistIdStr);
console.log('artistId:', artistId);
return await this.postService.artistAll(artistId);
}
또, NestJS에서는 @Param()으로 받은 값은 string 타입이기 때문에 Number()로 변환해줘야 한다!