I'm using Laravel API passport for my SPA Authentication using vue. So far what I made is each time I need to access my backend side I need to call header in able to accept by my protected route
const userObj = JSON.parse(window.localStorage.getItem('token'));
var header = {
'Accept' : 'application/json',
'Authorization' : 'Bearer '+ userObj.access_token
}
axios.get('/prod/test',{headers : header})
.then(response=>{
console.log(response);
});
}
Is there any much cleaner way to do this thanks