Can anyone help with this?
Mar 15, 2017
3
Level 6
How to consume Spark API when not authenticated
I'm a little bit confused on how best to consume my custom Spark API. Right now I have the Auth middleware applied to my API routes like so...
Route::group([
'middleware' => 'auth:api'
], function () {
...
}
Here is how I'm using Axios to call the API with Vue.js
methods: {
getCourses() {
axios.get('/api/courses')
.then(response => {
this.courses = response.data;
});
},
}
I'm getting the following error in the console when I'm not logged in
Failed to load resource: the server responded with a status of 401 (Unauthorized)
This obviously makes sense, since I have the 'Auth' middleware applied. However, I want for a Guest user to also to be able to see some pages where I make calls to the API. How would I fix this solution, while still keeping my API locked down with 'Auth' middleware?
Thanks.
Please or to participate in this conversation.