I have 3 express.js routes
app.get('/packages/:name', (req, res) => {...});
app.get('/packages/search/', (req, res) => {...});
app.get('/packages/search/:name', (req, res) => {...});
The first and thrid routes are working just fine.
But the second route is never triggert. When I browse to "localhost/packages/search/" it will trigger the first route with res.params.name = "search/"
I can do an "if" to check if its "search/" but i don't think thats a good solution.
Am I doing something wrong?
Routes in express.js are executed in order.
For detail Node.js Express route naming and ordering: how is precedence determined?
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