I am trying to consume my api using ajax (axios) request as the way it is instructed in laravel docs here. But it is not working, shows errors like the following image
My sample header response looks likes the following:
My ajax request looks like this:
axios.get('http://localhost:81/test_laravel/public/api/user')
.then(function(response){
console.log('Component mounted.')
})
.catch(function(error){
console.log(error.response.status)
});
Don't have a clue what is going on. Please help.
This works if I make a change in the \App\Http\EncryptCookies.php file like this:
Changing the value of $serializable by adding the line
protected static $serialize = true;
works.