node.js - express.js share routes to render page in different way -
i have written page called sponsorcenter
, need control 2 routes:
app.get('/sponsorcenter',function(req, res){}); app.get('/sponsorcenter/all',function(req, res){});
the header, footer , right columns same. when change url, left column change.
so question can use 1 route judge different access , render page? because left column different, think not necessary render other parts via route.
yes can accept route parameter variable. same variable accessible controller in request req
parameter.
app.get('sponsorcenter/:type*?', function(req, res) { console.log(req.params.type); });
this match routes sponsorcenter
, sponsorcenter/all
, sponsorcenter/admin
, sponsorcenter/user1
etc.
Comments
Post a Comment