Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const getProfile = () => {
logCallback('Get Profile Start', setProfileLoading(true));
KakaoLogins.getProfile()
.then(result => {
setProfile(result);
logCallback(
`Get Profile Finished:${JSON.stringify(result)}`,
setProfileLoading(false),
);
})
.catch(err => {
logCallback(
`Get Profile Failed:${err.code} ${err.message}`,
setProfileLoading(false),
);
});
};
const kakaoLogin = () => {
logCallback('Login Start', setLoginLoading(true));
KakaoLogins.login()
.then(result => {
setToken(result.accessToken);
logCallback(
`Login Finished:${JSON.stringify(result)}`,
setLoginLoading(false),
);
})
.catch(err => {
if (err.code === 'E_CANCELLED_OPERATION') {
logCallback(`Login Cancelled:${err.message}`, setLoginLoading(false));
} else {
logCallback(
`Login Failed:${err.code} ${err.message}`,
setLoginLoading(false),
);
}
const kakaoLogout = () => {
logCallback('Logout Start', setLogoutLoading(true));
KakaoLogins.logout()
.then(result => {
setToken(TOKEN_EMPTY);
setProfile(PROFILE_EMPTY);
logCallback(`Logout Finished:${result}`, setLogoutLoading(false));
})
.catch(err => {
logCallback(
`Logout Failed:${err.code} ${err.message}`,
setLogoutLoading(false),
);
});
};