[Vuejs]-401 (Unauthorized) with Laravel default vuejs setup

1👍

If you authorising user to use api you have to have a token either in url or in authorisation header key. That token should be from api_token column in users table.

var token = 'exampleToken';
axios.get(
    '/api/user?api_token=' + token, // here 
    { 
        headers:
            {
                'Authorization':'Bearer ' + token // or here
            }
    }
).then(...)

-1👍

axios.get('/api/user',{headers:{
     'Accept':'application/json',
     'Authorization':'Bearer ' + window.localStorage.getItem('token_name_here')
     'cache-control':'no-cache'
}).then(...)...

Leave a comment