Answer the question
In order to leave comments, you need to log in
How to connect Vue router and Slim?
Welcome all! I am writing an application on vue and slim, now I want to add routing on the client using Vue Router.
The essence of the problem is this: there is already written api on slim, all requests to it are transferred to this file, here is a super short example of it
$app = new \Slim\App;
/* --------- статистика --------- */
$app->group('/stat', function () {
$this->get('/graphs', function ($request, $response, $args) {
return "some data";
});
$app->run();
});
methods: {
fetchData () {
this.$http.get('http://localhost:8080/api/stat/graphs', {
}).then(response => {
console.log(response.data);
});
}
}
Answer the question
In order to leave comments, you need to log in
Do you have back and front running on the same port? Just usually 8080 is the front start port
Judging by the code, Vue router is definitely not trying to find anything. Now you just make a get http request, and the correct address is /stat/graphs, without any /api at the beginning.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question