We are creating a NodeJS application using express framework. While working with router params we encountered a unexpected behavior. API is being tested in postman as we don't have the frontend ready. There are two API defined as below
var router = express.Router();
router.get('/tif/:test2/:one', (req, res) => {
res.send("Test two");
});
router.get('/tif/test1/:one', (req, res) => {
res.send("Test one");
});
module.exports = router;
From postman we give an request 'http://localhost:3000/api/tif/test1/1', response received is 'Test two' wherein it should have responded 'Test one'. By changing the order of router I am able to get expected response 'Test one'. We are unable to reason out this behavior.