Skip to content
Advertisement

Two routes use params but only one is working

I’m trying to make a website that show you all the restaurants in the country with all th different cities. I add a route for restaurants that use params to redirect you to the restaurant page.

JavaScript

And another route that also use params to take you to the city details page

JavaScript

The problem is that only the restaurant route is working and when i delete the restaurant route, the city route start working . i don’t know why this is happening .

Advertisement

Answer

/:name and /:id are both on the same route(/). I have noticed that when this happens only the route that is seen first (/:name) would be recognised. You can try changing the route for one of them like /:name for the restaurant route and /restaurant/:id for the city route.

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement