From a7ab57b5ebb8675682737e3ce7a8783be0da7e00 Mon Sep 17 00:00:00 2001 From: swcho Date: Tue, 11 Nov 2025 15:43:21 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=ED=95=98=EC=88=98=EA=B4=80=EB=A1=9C=20?= =?UTF-8?q?=EB=A0=88=EC=9D=B4=EC=96=B4=20=ED=98=B8=EC=B6=9C=20api=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/sn/app/(map-layout)/map/page.tsx | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/apps/sn/app/(map-layout)/map/page.tsx b/apps/sn/app/(map-layout)/map/page.tsx index 651738642..90ec5a120 100644 --- a/apps/sn/app/(map-layout)/map/page.tsx +++ b/apps/sn/app/(map-layout)/map/page.tsx @@ -43,10 +43,27 @@ const Map = () => { const fetchData = async () => { try { - const data = await getData("v1/map/lyrStngs/SN_NETWORK"); + let data; + const res = await fetch("/sewerage-service/api/v1/map/lyrStngs/SN_NETWORK", { + method: "GET", + }); + if (res.ok) { + // 응답이 비어있는지 확인 + const contentLength = res.headers.get('content-length'); + if (contentLength === '0') data = null; + + // 응답 텍스트를 먼저 가져와서 빈 문자열인지 확인 + const text = await res.text(); + if (!text || text.trim() === '') data = null; + + // JSON 파싱 시도 + data = JSON.parse(text); + } setTreeData(data); } catch (error) { - console.error("데이터 불러오기 실패:", error); + console.error('JSON parsing error:', error); + // JSON 파싱에 실패한 경우, 원본 텍스트 또는 null 반환 + throw new Error('Invalid JSON response from server'); } };