I am using the express.js framework on node.js. I am trying to get the value of the first string argument from app.get() from within the callback.
app.get('/example/code', function(req,res){
console.log(firstParam); // "/example/code"
});
app.get('/example/:id', function(req,res){
console.log(firstParam); // "/example/:id"
});
app.get('/example(s?)', function(req,res){
console.log(firstParam); // "/example(s?)"
});
Any way to do this? As you can see I don’t want the url exactly, I want what the factor for the route was. For the second example I DO NOT WANT to return /example/2
You can get the path inside the callback with:
Among other info out of
req.route: