Reputation: 8499
I am using express.
I have 2 routes:
router.get('/:id', function (req, res, next) {
router.get('/search', function (req, res, next) {
Every time I call GET http://localhost:3000/users/search?name=@
I hit the fist route instead of the second one?
What should I change?
Upvotes: 2
Views: 159
Reputation: 6377
Because /:id
matches anything include /search
. It thinks the id is 'search'.
Try putting the '/search' route first, or change it to /find/:id
.
Upvotes: 5