Skip to content
Snippets Groups Projects
Commit d0d91915 authored by 한동현's avatar 한동현
Browse files

fix: API 조회 실패시 처리 수정

parent 04c931c4
Branches
No related tags found
No related merge requests found
......@@ -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();
})
......
......@@ -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]);
......
......@@ -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]);
......
......@@ -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]);
......
......@@ -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]);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment