Skip to content

Commit

Permalink
Merge pull request #50 from teamViNO/feature-059
Browse files Browse the repository at this point in the history
feature-059: 카카오 로그인 API 수정
  • Loading branch information
whistleJs authored Feb 9, 2024
2 parents 80dedb4 + 6e96860 commit a67c6df
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
5 changes: 5 additions & 0 deletions src/apis/social-account.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import axios from './config/instance';

export const kakaoLoginAPI = (token: string) => {
return axios.get(`/kakao-login?token=${token}`);
};
7 changes: 1 addition & 6 deletions src/apis/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,6 @@ export const joinAPI = (data: JoinRequest) => {
return axios.post<APIResponse<JoinResponse>>(PREFIX + '/join', data);
};

export const socialAccountAPI = (code: string) => {
return axios.get(`/sign-up/success?code=${code}`);
};

export const getNicknameAPI = () => {
return axios.get<APIResponse<getNicknameResponse>>(PREFIX + '/myPage/myInfo');
return axios.get<APIResponse<getNicknameResponse>>(PREFIX + '/myPage/myInfo');
};

11 changes: 7 additions & 4 deletions src/pages/SocialAccountPage.tsx
Original file line number Diff line number Diff line change
@@ -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');
}
};

Expand All @@ -19,11 +21,12 @@ const SocialAccountPage = () => {
const code = params.get('code');

if (!code) {
navigate('/sign-in');
return;
}

callAPI(code);
}, [search]);
});

return <div />;
};
Expand Down

0 comments on commit a67c6df

Please sign in to comment.