[Vuejs]-Vue use route params for axios get request

0👍

This should be this.$route.params.name inside the script.

const res = await axios.get(`http://localhost:3004/tests`,{ params: this.$route.params.name });

0👍

Router.js const routes = [ { path: ‘path/:name’, name: ‘Name’, component: ComponentName, } ]

0👍

I used @Nitheesh solution I just had to specify the parameter name and it worked perfectly
Solution:

const res = await axios.get(`http://localhost:3004/tests`,{ params: {name:this.$route.params.name} });

Leave a comment