I have a code like below
app.get('/all', callback2);
app.get('/:id', callback);
/:id is overriding the route /all.
The only solution I can think of, other than avoiding the use of potentially ambiguous routes, is to implement one route like this:
app.get('/:id', function(req, res) {
if (req.params.id === 'all') {
// do what you would do for /all
} else {
// do what you do for /:id
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With