[Vuejs]-I have Axios which returns 2 request from 2 controllers the second request does not return any data

0๐Ÿ‘

โœ…

I remove the second request and just move it in the mounted function and call this function whenever a row with id matches the record

    Products.showCat().then( data => {
      this.showCat = data.data
      // alert(this.showCat)
    })

0๐Ÿ‘

Could you check the order in which routes are defined in the backend.

You should define products/category before products/{id}
Otherwise when you call products/category the controller for products/{id} will be called with id = 'category'.

Maybe that is the issue for you.

Route ordering you should go for.

    Route::get('/products/category', 'ProductsCateogryController@category');

    Route::post('/products/{id}', 'BlahController@blah');

    Route::get('/products', 'BlahBlahController@blahBlah');

There will be issues if you define the routes in a different order.

You could add somekind of logging in your controllers to see which controller is actually being called.

    \Log::info('inside products');
    \Log::info('inside products/id');
    \Log::info('inside products/cateogry');

Leave a comment