Laravel 5.4 and Axios

Posted 2 years ago by brunowerneck

I've done a fresh install of the latest development version of Laravel 5.4 and I'm trying to "consume my own API", following the guide in the Laravel 5.3 documentation for installing Passport.

Whenever I try to make an ajax request to the api, like /api/user, I get the Unauthorized error, even though I followed all steps in the documentation.

In a regular 5.3.* installation, using Vue-Resource, it works like a breeze, but it is not working in Axios.

I can, however, create routes in the web.php routes file and query them using Axios with no further problems.

Does anyone have any idea of how to consume our own API using the API middleware and Axios?

Please sign in or create an account to participate in this conversation.

Laracasts Mascot

Hi, Have We Met Yet?

Did you know that, in addition to the forum, Laracasts includes well over 1000 lessons on modern web development? All for the price of one lunch out per month.

Sign Me Up

Channels

Reply to

Use Markdown with GitHub-flavored code blocks.