I have this piece of code:
/* GET projects page. */
router.get('/projects', function(req, res, next){
var sess = req.session,
projects = null;
if(!sess.login){
res.redirect('/login?r=projects');
return false;
}
var query = connection.query('SELECT id, name, created, last_edited, edited_by FROM projects', function(err, result) {
projects = result;
});
console.log(projects);
res.render('projects', {
title : 'Projects',
name : sess.login,
projects : projects
});
});
I'm trying to get all the results out as an array to be used in the page with jadejs, but projects never gets the data and remains null when called from the router script or the main page.