0👍
You don’t need the router
! Nuxt include an helper to catch parameters.
The name of your page file must be _name.vue
,
Then, to get the param, you can directly use context.params.name
.
Read the doc about dynamic routes : https://nuxtjs.org/guide/routing#dynamic-routes
Another point, enjoy the advantages offered by the ES6 to simplify your code 😉
async asyncData ({ params }) {
const { data } = await axios.get ('/users/' + params.name)
return {
user: data.info
}
}
Source:stackexchange.com