I'm developing a REST API using expressjs. I've two api endpoints as below:
router.get('/probe/:id', function() {});
router.get('/:id', function() {});
Now, when I call the first endpoint, the second endpoint is also called(with id as 'probe').
How can I make sure that only the first one is called?
I've defined them in the order as shown above.
EDIT
I was indeed calling next()
in one of the else
of my conditions.
Now, I've a new bug.
When I call the endpoint /probe/
- means there is no id
then only the second route is called and the first route is never called.
This the only time my code fails now.
What am I missing here?