I test an laravel 5.6
app running on localhost:8000
. I have a separated vue
project (not the one in laravel but external stand alone vue project) running on localhost:8080
.
I want external vue
to call a route from web.php
in laravel:
Route::get('/stores/{store}', 'StoresController@show');
My code in external vue
:
axios.get('http://localhost:8000/stores/68')///<-- I do have a record of 68 in database.
.then((response) => {
console.log(self.postdata);
}).catch((err) => {
console.log(err);
});
And I get error:
GET http://localhost:8000/stores/68 net::ERR_CONNECTION_REFUSED
I tried with IP address too:
axios.get('http://192.168.0.142:8000/stores/68')
And still get error:
GET http://192.168.0.142:8000/stores/68 net::ERR_CONNECTION_REFUSED
After much reading, I suspect is because of the csrf-token
don't exist in external vue
.
How can I resolve this?
Edit: Below are the screencap of the error from the console: