Commit 817ac51e authored by TTS Kieu Tuan Anh's avatar TTS Kieu Tuan Anh

get data response

parent e683fb3a
......@@ -48,6 +48,7 @@ export default {
</script>
<script>
const token = localStorage.getItem('bgcolor');
export default {
name: "logout",
data() {
......@@ -64,6 +65,7 @@ export default {
"Content-Type": "application/json",
},
body: JSON.stringify({
bearer_token: token,
}),
});
this.$router.push('/');
......
......@@ -82,8 +82,8 @@ export default {
};
},
methods: {
login() {
fetch("http://127.0.0.1:8000/api/login", {
async login() {
var resp = await fetch("http://127.0.0.1:8000/api/login", {
method: "POST",
headers: {
"Content-Type": "application/json",
......@@ -92,8 +92,20 @@ export default {
email: this.email,
password: this.password,
}),
});
}).then((response) => {
return response.json();
if(resp.data.bearer_token){
this.$router.push('home');
}
});
console.log(resp.data.bearer_token)
// localStorage.setItem('bgcolor', resp.data.bearer_token);
await this.$auth.setToken('local', "Bearer " + resp.data.bearer_token);
await this.$auth.setRefreshToken('local', resp.data.refresh);
await this.$auth.setUserToken(resp.data.access);
},
},
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment