I have two routes /emails
and /eamils/:id
:
var createRouter = function() {
var router = express.Router();
router.route('/emails/:id').get((req, res) => {
console.log('get=>/emails/id');
});
router.route('/emails').get((req, res) => {
console.log('get> /emails');
});
return router;
}
Whenever next request is sent the second handler gets called:
GET http://localhost:4000/rest-api/emails/?id=59
The first one which takes id
parameter never works. How can I fix this?
console.log('get> /emails);
? Just want to make sure this isn't a really simple mistype.