@Patch(':listId')
async update(@Param('listId', ParseIntPipe) listId: number, @Body() updateListDto: UpdateListDto) {
const data = await this.listsService.update(listId, updateListDto);
return {
statusCode: HttpStatus.OK,
message: '리스트 수정에 성공했습니다.',
data,
};
}
ParseIntPipe로 해결
이건 원래 코드 콘솔로 찍어보는데
@Patch(':listId')
async update(@Param('listId') listId: string, @Body() updateListDto: UpdateListDto) {
console.log('listId:', listId); // listId가 문자열인지 확인
console.log('typeof listId:', typeof listId); // listId의 타입을 확인
console.log('updateListDto:', updateListDto); // updateListDto 내용 확인
console.log('updateListId:', +listId); // updateListDto 내용 확인
const data = await this.listsService.update(+listId, updateListDto);
return {
statusCode: HttpStatus.OK,
message: '리스트 수정에 성공했습니다.',
data,
};
}
로직은 도는데 처음은 string이 나오고
요청값은 잘 들어오는데
+listId에서 객체로 변해서 id를 찾지 못하는거였다
'스파르타 내배캠 _과제, 프로젝트, 특강' 카테고리의 다른 글
웹개발 숙련 주차 과제 해설 강의 (0) | 2024.05.31 |
---|---|
개인과제 영화검색 해설강의 > 나중에 볼거 (0) | 2024.05.02 |