Node.js: How to properly return an object from within a callback?
You shouldn't want to do that. Callbacks are supposed to be asynchronous, so there is a chance that the code after the call to getMyGameQs is executed before the callback.
What you should do call "res.render" from inside the callback.
var tools = require('../models/tools.js'); app.get('/games', requireAuth, function (req, res) { var gameqlist = tools.getMyGameQs(req, function(err, gameqlist){ res.render('games', {title:'Your Games!', gameqlist : gameqlist}); }); });