Skip to content

Commit

Permalink
Feat: Add try catch
Browse files Browse the repository at this point in the history
  • Loading branch information
Ho-s committed Sep 7, 2024
1 parent d42231d commit a4f592e
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions src/search/search.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,21 @@ export class SearchService {
) {}

async suggest(keyword: string): Promise<string[]> {
const response = await this.httpService.axiosRef.get<{ items: any[] }>(
`https://m.map.kakao.com/actions/topSuggestV2Json?q=${encodeURIComponent(
keyword,
)}`,
{
responseType: 'json',
headers: KAKAO_SCRAPING_HEADERS,
},
);
return response.data.items.map((place) => place.key);
try {
const response = await this.httpService.axiosRef.get<{ items: any[] }>(
`https://m.map.kakao.com/actions/topSuggestV2Json?q=${encodeURIComponent(
keyword,
)}`,
{
responseType: 'json',
headers: KAKAO_SCRAPING_HEADERS,
},
);
return response.data.items.map((place) => place.key);
} catch (e) {
console.error(e);
throw new Error(e);
}
}

async searchPlaceList(
Expand Down

0 comments on commit a4f592e

Please sign in to comment.