I'm trying to render a page and pass a few variables across. I get an "undefined" error in browser and console shows the following GET request
GET/calendar?v=5708cc410e45c4603345c7a1 [object Object]
The route code is:
app.get('/calendar', isLoggedIn, function(req, res) {
var owner = 0;
user.find({user_id:req.query.v})
.lean()
.exec(function(err, data) {
owner = data;
})
res.render('calendar.ejs', {
user : req.user,
message: req.flash('postMessage'),
owner: owner
});
});
The route is receiving the query from client. I get the same error if I replace res.render with res.json(data) so it might be a database issue? But the DB query code is correct as far as I can tell...