From d0d91915521c0dacfedb4bb5fb1afa9cc72d1119 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=ED=95=9C=EB=8F=99=ED=98=84?= <hando1220@ajou.ac.kr> Date: Mon, 24 Mar 2025 15:14:49 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20API=20=EC=A1=B0=ED=9A=8C=20=EC=8B=A4?= =?UTF-8?q?=ED=8C=A8=EC=8B=9C=20=EC=B2=98=EB=A6=AC=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/forwarding/Edit.tsx | 4 +--- src/pages/forwarding/List.tsx | 9 +++++---- src/pages/routing/Create.tsx | 10 ++++++---- src/pages/routing/Edit.tsx | 15 +++++++-------- src/pages/routing/List.tsx | 9 +++++---- 5 files changed, 24 insertions(+), 23 deletions(-) diff --git a/src/pages/forwarding/Edit.tsx b/src/pages/forwarding/Edit.tsx index 7dac4eb..265ebf6 100644 --- a/src/pages/forwarding/Edit.tsx +++ b/src/pages/forwarding/Edit.tsx @@ -38,9 +38,7 @@ export default function ForwardingEdit() { useEffect(() => { authFetch(`/api/forwarding?forwardingId=${id}`) .then((response) => { - if (!response.ok) { - throw Error(); - } + if (!response.ok) throw Error(`포트포워딩 정보 조회 실패: ${response.status}`); return response.json(); }) diff --git a/src/pages/forwarding/List.tsx b/src/pages/forwarding/List.tsx index 3fa1999..b924b2e 100644 --- a/src/pages/forwarding/List.tsx +++ b/src/pages/forwarding/List.tsx @@ -29,15 +29,16 @@ export default function ForwardingList() { useEffect(() => { authFetch(`/api/forwardings?projectId=${selectedProject?.id}`) .then((response) => { - if (!response.ok) { - toast.error('포트포워딩 정보를 조회할 수 없습니다.'); - return { forwardings: [] }; - } + if (!response.ok) throw Error(`포트포워딩 목록 조회 실패: ${response.status}`); return response.json(); }) .then(({ contents }) => { setForwardings(contents); + }) + .catch((error) => { + console.error(error); + toast.error('포트포워딩 정보를 조회할 수 없습니다.'); }); }, [authFetch, selectedProject]); diff --git a/src/pages/routing/Create.tsx b/src/pages/routing/Create.tsx index 8011001..c60b5f1 100644 --- a/src/pages/routing/Create.tsx +++ b/src/pages/routing/Create.tsx @@ -75,14 +75,16 @@ export default function RoutingCreate() { if (enableSSL) { authFetch(`/api/certificates?projectId=${selectedProject?.id}&domain=${debouncedDomain}`) .then((response) => { - if (!response.ok) { - toast.error('SSL 인증서 목록을 불러올 수 없습니다'); - return { contents: [] }; - } + if (!response.ok) throw Error(`SSL 인증서 목록 조회 실패: ${response.status}`); + return response.json(); }) .then(({ contents }) => { setCertificates(contents); + }) + .catch((error) => { + console.error(error); + toast.error('SSL 인증서 목록을 불러올 수 없습니다.'); }); } }, [authFetch, enableSSL, selectedProject, debouncedDomain]); diff --git a/src/pages/routing/Edit.tsx b/src/pages/routing/Edit.tsx index 6a40926..0520a9a 100644 --- a/src/pages/routing/Edit.tsx +++ b/src/pages/routing/Edit.tsx @@ -78,10 +78,7 @@ export default function RoutingEdit() { useEffect(() => { authFetch(`/api/routing?routingId=${id}`) .then((response) => { - if (!response.ok) { - console.error(response); - throw Error(); - } + if (!response.ok) throw Error(`라우팅 정보 조회 실패: ${response.status}`); return response.json(); }) @@ -116,14 +113,16 @@ export default function RoutingEdit() { if (enableSSL) { authFetch(`/api/certificates?projectId=${selectedProject?.id}&domain=${debouncedDomain}`) .then((response) => { - if (!response.ok) { - toast.error('SSL 인증서 목록을 불러올 수 없습니다'); - return { contents: [] }; - } + if (!response.ok) throw Error(`SSL 인증서 목록 조회 실패: ${response.status}`); + return response.json(); }) .then(({ contents }) => { setCertificates(contents); + }) + .catch((error) => { + console.error(error); + toast.error('SSL 인증서 목록을 불러올 수 없습니다.'); }); } }, [authFetch, enableSSL, selectedProject, debouncedDomain]); diff --git a/src/pages/routing/List.tsx b/src/pages/routing/List.tsx index a50c4dc..d1e5b46 100644 --- a/src/pages/routing/List.tsx +++ b/src/pages/routing/List.tsx @@ -30,15 +30,16 @@ export default function RoutingList() { useEffect(() => { authFetch(`/api/routings?projectId=${selectedProject?.id}`) .then((response) => { - if (!response.ok) { - toast.error('라우팅 정보를 조회할 수 없습니다.'); - return { contents: [] }; - } + if (!response.ok) throw Error(`라우팅 목록 조회 실패: ${response.status}`); return response.json(); }) .then(({ contents }) => { setRoutings(contents); + }) + .catch((error) => { + console.error(error); + toast.error('라우팅 정보를 조회할 수 없습니다.'); }); }, [authFetch, selectedProject]); -- GitLab