Skip to content

Commit

Permalink
fix: 비동기 처리
Browse files Browse the repository at this point in the history
  • Loading branch information
urjimyu committed May 27, 2024
1 parent f980d6e commit 732b70d
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src/pages/KakaoLoginPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,31 +15,34 @@ const KakaoLoginPage = () => {
const handlePostKakao = async (code: string) => {
try {
await postKakao(code);
console.log('KakaoResponse', kakaoResponse);
if (!kakaoError && !kakaoLoading && kakaoResponse) {
console.log('이동 전 콘솔 찍히는지 확인', kakaoResponse);
console.log('이동 전 콘솔 확인', kakaoResponse);
if (kakaoResponse.isAlreadyUser) {
navigate('/delete');
} else {
navigate('/unregistered');
}
}
} catch (error) {
navigate('/unregistered');
console.log('ERROR', error);
navigate('/unregistered');
}
};

useEffect(() => {
useGetToken()
.then((res) => {
const fetchLogin = async () => {
try {
const res = await useGetToken();
if (res) {
const token = res.data.access_token;
// localStorage.setItem('ACCESS_TOKEN', JSON.stringify(token));
handlePostKakao(token);
await handlePostKakao(token);
}
})
.catch((err) => console.log(err));
} catch (err) {
console.log(err);
}
};
fetchLogin();
}, []);

return <></>;
Expand Down

0 comments on commit 732b70d

Please sign in to comment.