Let me rephrase my question. How do I get the data which comes back in an array to render. (I am using handlebars)
The Code:
//http verbs
module.exports = {
get: function(req, res) {
gm(req.url);
app.set('view engine', 'hbs');
//session check
if (session checks out<-not actual code){
//get mongoose data here
var bmdata = bmquery.execFind(function(err, docs){
console.log(docs);
var model = {
layout:'blog.hbs',
BlogModel: docs,
};
//render page
res.render('blog', model);
});
}
else {
console.log('illegal user');
console.log('redirection in progress');
res.redirect('/login');
}
}
};
The console.log of docs comes back in an array like so: [{document 1},{document 2}]
Could you also do this dynamically so that I do not have to put the array position.
My handlebars looks like this:
{{BlogModel[0].title}}
{{BlogModel[0].content}}
{{BlogModel[1].title}}
{{BlogModel[1].content}}
The Problem Data comes back in an array and I cant get it to render out dynamically or at all.