From 96e7bceef7168ced8acda2aace26e0ec8c3612c6 Mon Sep 17 00:00:00 2001 From: woong Date: Thu, 1 Aug 2024 13:42:12 +0900 Subject: [PATCH] Fix: handling of absent photoList, periodList --- src/search/search.service.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/search/search.service.ts b/src/search/search.service.ts index ce717c7..904ed4d 100644 --- a/src/search/search.service.ts +++ b/src/search/search.service.ts @@ -167,7 +167,7 @@ export class SearchService { kakaoPlace.commentCnt = feedback.comntcnt; kakaoPlace.mainPhotoUrl = basicInfo.mainphotourl; kakaoPlace.score = feedback.scoresum / feedback.scorecnt; - kakaoPlace.openTimeList = basicInfo.openHour.periodList.flatMap( + kakaoPlace.openTimeList = (basicInfo.openHour?.periodList || []).flatMap( (period) => period.timeList, ); kakaoPlace.offDayList = basicInfo.openHour.offdayList; @@ -193,8 +193,8 @@ export class SearchService { kakaoPlace.y = coord.y; // TODO: 음식사진 가져오는것도 약간 우선순위를 두면 좋을듯 - kakaoPlace.photoList = kakaoPlaceRaw.photo.photoList - .flatMap((photo) => photo.list) + kakaoPlace.photoList = (kakaoPlaceRaw.photo?.photoList || []) + .flatMap((photo) => photo.list || []) .map((photo) => photo.orgurl) .slice(0, 10); await this.kakaoPlaceRepository.upsert(kakaoPlace);