How to write a statement in laravel to determine the expiration of a logged-in user's session?
There is an ajax request that can return data when the user logs in. When the session expires, it will jump to the login page. How to do this?
axios.get('/admin/articles')
.then(response=>{
console.log(response.data);
})
.catch(error=>{
console.log(error);
});
習慣沉默2017-07-04 13:47:48
Expired, will return 401
status code
By default, axios will throw 401
to error
. You can handle the 401
status code in catch
and jump to the login page.