Skip to content

Commit b8f7c22

Browse files
committed
feat: logout API 추가
1 parent 6da8353 commit b8f7c22

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/apis/auth.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import useAuthStore from '@/stores/authStore';
12
import client from './client';
23

34
type LoginType = 'kakao' | 'naver' | 'google';
@@ -8,6 +9,20 @@ export const socialLogin = (loginType: LoginType) => {
89
window.location.href = `http://13.209.132.150:8081/oauth2/authorization/${loginType}`;
910
};
1011

12+
export const logout = async () => {
13+
const { accessToken } = useAuthStore.getState();
14+
try {
15+
const response = await client.post(`/api/logout`, {
16+
Authorization: { token: `Bearer ${accessToken}` },
17+
withCredentials: true,
18+
});
19+
if (!response) throw new Error('logout fail');
20+
return response;
21+
} catch (error) {
22+
console.error(error);
23+
}
24+
};
25+
1126
//임시 코드
1227
export const getUserToken = async (stateToken: string) => {
1328
try {

0 commit comments

Comments
 (0)