0👍
✅
There are various ways of doing the same, you can use cookies or local storage,
Laravel Password mostly validates the request using token so if you are using Vue Auth at front end you can define a constructor to send the token every time you send a request.
constructor() {
let userToken = window.localStorage.getItem('token');
let userData = window.localStorage.getItem('user');
if (typeof userToken !== 'undefined' || typeof userData !== 'undefined') {
this.user = userData;
this.token = userToken;
} else {
this.user = null;
this.token = null;
}
if (this.token !== null && this.token !== 'undefined') {
axios.defaults.headers.common['Authorization'] = 'Bearer ' + this.token;
} else {
this.authenticated = false;
this.logout();
}
0👍
i use this in app.js
if (store.state.user.token !== undefined) {
axios.defaults.headers.common['Authorization'] = "Bearer " + store.state.user.token
}
but for what createFreshApiToken then?
Source:stackexchange.com