I'm stuck trying to get mongodb data in my jade views. I'm a newbie with node.js and I apologize if this seems stupid! I can see what's in my table in the console:
Material.find(function (err, materials){
console.log(materials);
});
But I want to pass that data to my jade view
app.get('/help', function(req, res){
res.render('help', {materials: materials});
});
How can I do that?
You're on the right track! Just put the rendering in the callback from the find
:
app.get('/help', function(req, res){
Material.find(function (err, materials){
res.render('help', {materials: materials});
});
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With