From 656e135e9102289e419b2c7de6af363ce649a745 Mon Sep 17 00:00:00 2001 From: beom-jun Date: Sat, 2 Nov 2024 20:16:58 +0900 Subject: [PATCH 1/2] =?UTF-8?q?=EC=82=AC=EC=9A=A9=EC=9E=90=EC=A1=B0?= =?UTF-8?q?=ED=9A=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/ExistingUserPage.jsx | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/pages/ExistingUserPage.jsx b/src/pages/ExistingUserPage.jsx index 614471d..8a119de 100644 --- a/src/pages/ExistingUserPage.jsx +++ b/src/pages/ExistingUserPage.jsx @@ -12,22 +12,24 @@ const ExistingUserPage = () => { e.preventDefault(); if (nickname.trim()) { try { - // 사용자 조회 - const response = await axios.post(`https://junyeongan.store/api/diary?userNickname=${nickname.trim()}`); + // 사용자 조회 - 닉네임 파라미터 추가 + const response = await axios.get(`https://junyeongan.store/api/member/check?nickname=${nickname.trim()}`); - // 사용자가 이미 존재하는 경우 캘린더로 이동 - if ((response.status === 400 && - response.data?.details === "MEMBER_ALREADY_EXISTS")) { + if (response.status === 200) { localStorage.setItem('userNickname', nickname.trim()); navigate('/calendar'); } } catch (error) { - // 사용자 조회 실패 시 if (error.response?.status === 404 && error.response?.data?.details === "MEMBER_DOES_NOT_EXISTS") { toast.error('존재하지 않는 닉네임입니다. 다시 확인해주세요.'); + } else if (error.response?.status === 400 && + error.response?.data?.details === "MEMBER_ALREADY_EXISTS") { + localStorage.setItem('userNickname', nickname.trim()); + navigate('/calendar'); } else { toast.error('오류가 발생했습니다. 다시 시도해주세요.'); + console.error('Error:', error); } } } From 4e6849da81b651692a20be5a8e0e642baaf4e97a Mon Sep 17 00:00:00 2001 From: beom-jun Date: Sat, 2 Nov 2024 20:50:21 +0900 Subject: [PATCH 2/2] befoer-merge --- src/pages/ExistingUserPage.jsx | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/pages/ExistingUserPage.jsx b/src/pages/ExistingUserPage.jsx index 8a119de..bba2f21 100644 --- a/src/pages/ExistingUserPage.jsx +++ b/src/pages/ExistingUserPage.jsx @@ -12,7 +12,6 @@ const ExistingUserPage = () => { e.preventDefault(); if (nickname.trim()) { try { - // 사용자 조회 - 닉네임 파라미터 추가 const response = await axios.get(`https://junyeongan.store/api/member/check?nickname=${nickname.trim()}`); if (response.status === 200) { @@ -20,13 +19,8 @@ const ExistingUserPage = () => { navigate('/calendar'); } } catch (error) { - if (error.response?.status === 404 && - error.response?.data?.details === "MEMBER_DOES_NOT_EXISTS") { + if (error.response?.status === 400) { toast.error('존재하지 않는 닉네임입니다. 다시 확인해주세요.'); - } else if (error.response?.status === 400 && - error.response?.data?.details === "MEMBER_ALREADY_EXISTS") { - localStorage.setItem('userNickname', nickname.trim()); - navigate('/calendar'); } else { toast.error('오류가 발생했습니다. 다시 시도해주세요.'); console.error('Error:', error);