Answer the question
In order to leave comments, you need to log in
How to implement routing correctly?
In nuxt, all routing is automatically built from the pages folder.
In this folder I have a dynamic folder called _tag/index.vue and it also contains a dynamic folder _card/index.vue.
Structure:
pages
---- _tag/
------ index.vue
------ _card/
------ index.vue
What's the point. When I enter a query into the address bar, for example, localhost:3000/na-karty , I give the text for the page and a list of cards. These cards are, let's say, goods. When I click on one of the cards, I go to the page, respectively, I make another request, where I give the text and other data for this page.
But the problem is that I can't figure out how to make a request correctly. I went to the na-karty page and went to a card like service-one. The address bar should have something like this localhost:3000/na-karty/service-one . This is logically correct. And it is feasible with the help of a banal api request.
And everything seems to be working. If I enter a card page that doesn't exist, such as localhost:3000/na-karty/service-two , I get an error that the page doesn't exist.
But the main problem is that when I enter a non-existent address of the first page (tag), for example, localhost: 3000 na-karty lol/service-one, then there is no error. Although it should be, because The original address is incorrect. How can this be avoided and corrected?
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question