Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Rockett's avatar

User auth and Axios API calling

In my app, a user can create posts, but I want users to only see their own created posts.

I want to make it an SPA, using Axios to get the post data, and map the data in a list (using React instead of Blade directives). My React components are NOT ejected from the Laravel project. I am rendering them inside a blade file.

I am getting 401 unauthorised errors from the Axios calls. What steps do I need to take to get successful calls?

Do I actually need to use a different type of authentication? (api tokens, passport, JWT)?

Thanks in advance

0 likes
2 replies
tykus's avatar
tykus
Best Answer
Level 104

Do I actually need to use a different type of authentication?

How are you authenticating a user already?

I am getting 401 unauthorised errors from the Axios calls.

Are you authorizing access to the resource(s) on the Laravel side?

1 like

Please or to participate in this conversation.