From 56563634afd3cde020d115416ad2999e5a0740ae Mon Sep 17 00:00:00 2001 From: "Gabriel Ju Hyun, Yoon" Date: Tue, 10 Oct 2023 14:58:59 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=EB=8C=80=EB=8F=84=EC=8B=9C=20=EB=A7=88?= =?UTF-8?q?=EC=BB=A4=20=EB=A0=8C=EB=8D=94=EB=A7=81=20=EC=98=A4=EB=A5=98?= =?UTF-8?q?=EB=A5=BC=20=EC=88=98=EC=A0=95=ED=95=9C=EB=8B=A4=20(#846)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * refactor: 지역 마커 수신에 대한 에러 핸들링 [#845] * fix: 잘못 된 url 수정 [#845] --- .../hooks/useRegionMarkers.ts | 13 +++++++------ .../station-markers/stationMarkerHandlers.ts | 2 +- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/frontend/src/components/google-maps/marker/MaxDeltaAreaMarkerContainer/hooks/useRegionMarkers.ts b/frontend/src/components/google-maps/marker/MaxDeltaAreaMarkerContainer/hooks/useRegionMarkers.ts index 7f6207d7c..df81c25f6 100644 --- a/frontend/src/components/google-maps/marker/MaxDeltaAreaMarkerContainer/hooks/useRegionMarkers.ts +++ b/frontend/src/components/google-maps/marker/MaxDeltaAreaMarkerContainer/hooks/useRegionMarkers.ts @@ -6,15 +6,16 @@ import { SERVER_URL } from '@constants/server'; import type { Region } from '../types'; export const fetchRegionMarkers = async () => { - const stationMarkers = await fetch(`${SERVER_URL}/stations/markers/regions?regions=all`) - .then(async (response) => { + const stationMarkers = await fetch(`${SERVER_URL}/stations/regions?regions=all`).then( + async (response) => { + if (!response.ok) { + throw new Error('지역 마커를 수신을 실패했습니다.'); + } const data = await response.json(); return data; - }) - .catch((error) => { - throw new Error('지역 마커를 수신을 실패했습니다.', error); - }); + } + ); return stationMarkers; }; diff --git a/frontend/src/mocks/handlers/station-markers/stationMarkerHandlers.ts b/frontend/src/mocks/handlers/station-markers/stationMarkerHandlers.ts index 2e7c142e1..9679d5fa3 100644 --- a/frontend/src/mocks/handlers/station-markers/stationMarkerHandlers.ts +++ b/frontend/src/mocks/handlers/station-markers/stationMarkerHandlers.ts @@ -106,7 +106,7 @@ export const stationMarkerHandlers = [ }) ); }), - rest.get(`${DEVELOP_SERVER_URL}/stations/markers/regions`, async (req, res, ctx) => { + rest.get(`${DEVELOP_SERVER_URL}/stations/regions`, async (req, res, ctx) => { const { searchParams } = req.url; const region = searchParams.get('regions');