1

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.

3

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.