Node, express, mongoose.
I am trying to add an Array as an element to an Array from a callback.
app.get('/view', function(req, res){
var csvRows = [];
Invitation.find({}, function(err, invitations){
if(err){
console.log('error');
} else {
invitations.forEach(function(invitation){
Guest.find({_id: invitation.guests}, function(err, guest){
if(err){
} else {
var rsvpURL = 'url'+invitation._id;
var csvRow = [guest[0].firstName,
guest[0].addr1,
...,
rsvpURL];
csvRows.push(csvRow);
}
});
});
console.log(csvRows);
res.send(csvRows);
}
});
});
The array gets nothing added to it. Any thoughts will be greatly appreciated.