From 6e9686014f85499b6fdaa736d6f603b824a4fe75 Mon Sep 17 00:00:00 2001 From: whistleJs Date: Fri, 9 Feb 2024 19:31:31 +0900 Subject: [PATCH] =?UTF-8?q?feature-059:=20=EC=B9=B4=EC=B9=B4=EC=98=A4=20?= =?UTF-8?q?=EB=A1=9C=EA=B7=B8=EC=9D=B8=20API=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/apis/social-account.ts | 5 +++++ src/apis/user.ts | 7 +------ src/pages/SocialAccountPage.tsx | 11 +++++++---- 3 files changed, 13 insertions(+), 10 deletions(-) create mode 100644 src/apis/social-account.ts diff --git a/src/apis/social-account.ts b/src/apis/social-account.ts new file mode 100644 index 0000000..daaa2e1 --- /dev/null +++ b/src/apis/social-account.ts @@ -0,0 +1,5 @@ +import axios from './config/instance'; + +export const kakaoLoginAPI = (token: string) => { + return axios.get(`/kakao-login?token=${token}`); +}; diff --git a/src/apis/user.ts b/src/apis/user.ts index 9d02156..e56f735 100644 --- a/src/apis/user.ts +++ b/src/apis/user.ts @@ -50,11 +50,6 @@ export const joinAPI = (data: JoinRequest) => { return axios.post>(PREFIX + '/join', data); }; -export const socialAccountAPI = (code: string) => { - return axios.get(`/sign-up/success?code=${code}`); -}; - export const getNicknameAPI = () => { - return axios.get>(PREFIX + '/myPage/myInfo'); + return axios.get>(PREFIX + '/myPage/myInfo'); }; - diff --git a/src/pages/SocialAccountPage.tsx b/src/pages/SocialAccountPage.tsx index 480fbf6..49e8293 100644 --- a/src/pages/SocialAccountPage.tsx +++ b/src/pages/SocialAccountPage.tsx @@ -1,16 +1,18 @@ import { useEffect } from 'react'; -import { useLocation } from 'react-router-dom'; +import { useLocation, useNavigate } from 'react-router-dom'; -import { socialAccountAPI } from '@/apis/user'; +import { kakaoLoginAPI } from '@/apis/social-account'; const SocialAccountPage = () => { + const navigate = useNavigate(); const { search } = useLocation(); const callAPI = async (code: string) => { try { - console.log(await socialAccountAPI(code)); + console.log(await kakaoLoginAPI(code)); } catch (e) { console.error(e); + navigate('/sign-in'); } }; @@ -19,11 +21,12 @@ const SocialAccountPage = () => { const code = params.get('code'); if (!code) { + navigate('/sign-in'); return; } callAPI(code); - }, [search]); + }); return
; };