What I currently do is is in my app.js// global vars app.locals.base_url = "http://ift.tt/2s3JdPi" and then in my routes/index.jsrouter.get('/trivia', function(req, res) { var db = req.db; var collection = db.collection('trivaquestions'); collection.find({}).toArray(function(err, docs_triviaquestions) { res.render('trivia', { "triviaquestionslist": JSON.stringify(docs_triviaquestions) params: { base_url: req.app.locals.base_url } }); }); }); I then reference it in my template but I wanted to know if I can do something easier, for example setting the variable in my route or...what do most people do?
Submitted June 29, 2017 at 01:30AM by InsertCoinPushStart
No comments:
Post a Comment