logout(){
var destroySession='{"token":"'+this.token+'"}'
console.log("Session Destroy"+destroySession)
axios.post(eventBus.apiURL+'logout',{
headers: {
'Content-type': 'application/json',
},
body: destroySession,
}).then(response=>{
console.log("RESadas :: "+JSON.stringify(response.data))
alert("Logout successfully..!")
this.$router.push('/')
},error=>{
console.log(error);
alert("Some Issue for LogOut at Server Side..!")
});
window.localStorage.removeItem('token')
window.localStorage.removeItem('name')
this.$router.push('/')
}
<button @click="logout">Logout</button>
我在vuejs
書面退出代碼2 AJAX POST請求,但在單擊時它發送兩個POST
請求和會話銷燬時問題發生在服務器端。
所以你想發送2個請求到服務器,或者你有問題,因爲2個請求正在發送到服務器?如果是後者,當第一個請求開始時,您可以將「禁用」屬性添加到按鈕。 –
問題是2請求正在發送 – AshD