0% found this document useful (0 votes)
4 views1 page

81. Nested Routes

The document discusses the implementation of a nested route for creating reviews associated with a specific tour ID in tourRoutes.js. A new route is defined to handle POST requests for creating reviews, allowing for a more organized structure. It also mentions the need to simplify the use of functions from reviewController within tourRoutes.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views1 page

81. Nested Routes

The document discusses the implementation of a nested route for creating reviews associated with a specific tour ID in tourRoutes.js. A new route is defined to handle POST requests for creating reviews, allowing for a more organized structure. It also mentions the need to simplify the use of functions from reviewController within tourRoutes.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

So when creating a review, we used seperate routes for get all the reviews and create a new review.

What about we want to create a review on route for tour id like tour/alskdjaaasşldkas/review

So for that, in [Link], we create another route:

[Link](‘/:tourId/reviews’).post([Link], [Link], [Link]).

Since we specified a nested route and called a post requet on it, it can work now.

But it’s a bit cumbersome to use function from reviewController for tourRoutes. Let’s handle that.

You might also like