A Commonly asked question but I simply cannot get it to work,
I'm trying to in the smoothest way possible pass all items that I get from my mongodb query to my Jade view 'index'. Preferably so that I in jade can access all the data like this:
for item in items
p= item.title
p= item.location
p= item.comment
This is the code (just trying to pass one item for simplicity)
exports.viewHome = function(req, res){
db.collection('items', function(err, collection){
collection.find({}, function(err, items){
items.toArray(function(err, items){
res.render('index', {items:items});
});
});
});
}
And this is what JSON.stringify(items[0]); gives me
{"titel":"hello","location":"Stockholm","comments":"Great Things","_id":"510686df1165986e0f000001"}
Trying to access anything with item.title in jade outputs nothing(undefined)