express-enrouten
express-enrouten copied to clipboard
Route name query
I have added a named route and would like to know how will I get the same via request object.
I want to know the name of the route which got matched.
Example:
router({ path: '/user/:id', name: 'user-info' }) .get(function (req, res) { //Here I am looking for route name which got matched. res.send(req.route.name); });
@tapankumar You can get it using req.baseUrl. We still have access to the same express's Request object as we used to while writing using plain express.