Linked Questions

Popular Questions

Axios call to laravel backend in nuxt.js

Asked by At

I am trying to get a laravel-nuxt project running. I am stuck with creating route calls to my laravel backend using axios async call to serve up data to my nuxt frontend before loading the page.

I am constantly getting getting a 404 with my current laravel-nuxt setup even though I have the route defined in api.php.

I am using this as a template for the project and I have not changed anything in that template yet:

So my frontend call is this here:

async asyncData ({ $axios }) {
  if (process.server) {
    return $axios.$get('/api/data')
    .then((res) => { =;

And my backend route is defined as follows in api.php:

Route::get('/data', '[email protected]');

It always gives me a 404, is there something missing that I should be aware of?

Related Questions