Home » vue » How to access id from a nested route in nuxt

How to access id from a nested route in nuxt

Posted by: admin November 26, 2021 Leave a comment

Questions:

In my nuxt app the nested url looks like this.

http://lvh.me:8001/categories/:id/sections/:id

http://lvh.me:8001/categories/40/sections/12

How can I access the categories id from this page?
$route.params.id only returns the id of sections which is 12. Is there a way to access the id of categories?

Answers:

you have to change the parameter name they can’t use same name

http://lvh.me:8001/categories/:id1/sections/:id2