How to pass parameter to routes?
问题 I am using Nodejs . Server.js app.get('/dashboard/:id', routes.dashboard); Routes / index.js exports.dashboard = function(req, res){ } I want to be able to pass the 'id' variable from app.js to the dashboard function . How do I go about doing this ? 回答1: Assuming ExpressJS, you shouldn't need to pass it. For each parameter placeholder (like :id ), req.params should have a matching property holding the value: exports.dashboard = function (req, res) { console.log(req.params.id); }; Though, this