Commit 47bd40b3 authored by TTS Kieu Tuan Anh's avatar TTS Kieu Tuan Anh

axios logout

parent 63274c7a
......@@ -43,22 +43,32 @@
export default {
methods: {
logout () {
fetch('http://127.0.0.1:8000/api/logout', {
method: 'POST',
async logout () {
try {
const resp = await this.$axios.post('/logout', {
token: this.$auth.$storage.getUniversal('token')
},
{
headers: {
'Content-Type': 'application/json',
accept: 'application/json'
},
body: JSON.stringify({
token: this.$auth.$storage.getUniversal('token')
}
})
if (resp.status == '200') {
this.$toast.success('Successfully authenticated', {
duration: 2000
})
this.$router.push('/login')
localStorage.setItem('token', '')
this.$auth.$storage.setUniversal('loggedIn', 'false')
this.$auth.$storage.setUniversal('token', '')
this.$auth.$storage.setUniversal('userName', '')
this.$router.push('/login')
}
} catch (e) {
this.$toast.error('ERR !', {
duration: 2000
})
}
}
}
}
......
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