0ussama
1 week ago
88
2
Vue

how vue router works in laravel

Posted 1 week ago by 0ussama

i've been learning vue router lately with laravel, following bunch of tutorials (building SPAs), i noticed they add in web.php :

#example 1
Route::any('{any}', function () {
    return view('home');
})->where('any', '.*');
#example2
Route::fallback('[email protected]');
#example 3
Route::get('{path}', '[email protected]')->where('path', '([A-z\d\-/_.]+)?');

to catch all routes wlidcards. my question is how the conversion happens from 'backend routing' to an SPA routing, cause i faced issues with axios, when i do

axios.get("api/clients/1").then(response => {
        console.log(response.data);
      });

inside a ClientInfos.vue component, it gives me back the home view as a response, but when i do

axios.get("../api/clients/1").then(response => {
        console.log(response.data);
      })

i get the proper response i wanted, any explanation to this? thnx

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