Skip to content
Snippets Groups Projects
Commit ab6fcfb4 authored by 조 지현's avatar 조 지현
Browse files

logout 분리

parent dea857f9
No related branches found
No related tags found
No related merge requests found
......@@ -2,6 +2,7 @@
import axios from "axios";
import CryptoJS from "crypto-js";
import fetchData from "@/store/fetchData";
import logout from "@/store/logout.js";
export default {
......@@ -52,24 +53,17 @@ export default {
}
},
async logout() {
// await logout.logout();
// fetch 해서 login 정보의 access 토큰을 들고와서 : 나중에 fetchData 분리 처리
const response = await axios.get("https://172.16.0.60:8443/api/auth/logout", {
headers: {
// accessToken 을 들고온 값을 여기 넣어주고
"Authorization": `Bearer ${this.$store.state.user.info.accessToken}`,
},
async logout() {
const response = await logout.logout();
})
console.log(response)
// 로그인 상태일때 "로그아웃" 실행
if(response.status === 200){
// user 값을 빈객체 null 혹은 {} 로 clear 해주기
this.$store.commit("setUserData", {});
console.log("로그아웃")
console.log("로그아웃 성공")
}else{
console.log("로그아웃 실패")
}
......
import axios from "axios";
import store from "@/store/store.js";
// 로그인되어있는 상태에서 accessToken 값을 뽑아와서 header 에 실어보내 매칭시키고 clear 로
export default {
async logout() {
// fetch 해서 login 정보의 access 토큰을 들고와서 : 나중에 fetchData 분리 처리
const response = await axios.get("https://172.16.0.60:8443/api/auth/logout", {
return await axios.get("https://172.16.0.60:8443/api/auth/logout", {
headers: {
// accessToken 을 들고온 값을 여기 넣어주고
"Authorization": `Bearer ${this.$store.state.user.info.accessToken}`,
// this.$store 가 인식되지 않아 state 오류가 났고 store 를 import 해주었다.
"Authorization": `Bearer ${store.state.user.info.accessToken}`,
},
})
console.log(response)
// 로그인 상태일때 "로그아웃" 실행
if(response.status === 200){
// user 값을 빈객체 null 혹은 {} 로 clear 해주기
this.$store.commit("setUserData", {});
console.log("로그아웃")
}else{
console.log("로그아웃 실패")
}
// console.log(response)
//
// // 로그인 상태일때 "로그아웃" 실행
// if(response.status === 200){
// // user 값을 빈객체 null 혹은 {} 로 clear 해주기
// this.$store.commit("setUserData", {});
// console.log("로그아웃 성공")
// }else{
// console.log("로그아웃 실패")
// }
},
};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment