'Express separate two routes that are only different by req.params
Hi I am trying to build a CRUD application to get items by name and location.
Here are the two routes I have so far:
app.get('/items/:name', function (req, res) {
console.log("get items by name");
});
app.get('/items/:location', function (req, res) {
console.log("get items by city");
});
However, my second route cannot be reached. It always reach the first get route and logs "get items by name". What should I do to fix this? Ty:)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|