Reputation: 29
So one of my routes in my express app has you search for a contact. (/contact). It goes off of the req.query to pull the information to search.
However, I'd like to add an option for /contact/:contact_id in case the user doesn't need to search for it. It's a lot easier than adding contact_id to the parameters for the end user if they already know the contact_id.
Can I have both a /contact and /contact/:contact_id and have them work properly? Or do I need to make /contact/:contact_id and add in an if statement to check if they have the contact id already?
Upvotes: 0
Views: 70
Reputation: 5245
You can have both /contact
and /contact/:contact_id
routes and the order in which you declare the routes do not matter.
Upvotes: 1