Reputation: 99
Routes in main.js
{
name: 'match',
path: '/match/:id',
component: Match,
props: true
},
And in the main component (separate file) that fires the GET request:
axios({
method: "GET",
url: "/match/" + id,
crossdomain: true,
)}
Chrome tells me it's a 404. But when I open the provided link, it resolves and works?
Upvotes: 0
Views: 974
Reputation: 725
You should try
this.$router.push("/match/" + id)
While 'this' is a Vue instance. You need to use vue-router API to navigate inside your application, not axois.
Upvotes: 1
Reputation: 99
Solved by changing component Axios call to
url: this.$router.push({ name: 'match', params: { id: id }})
As per https://router.vuejs.org/guide/essentials/named-routes.html
Upvotes: 0