Trying to display data from mongodb database in node.js app -


server.get('/', function(req, res) {     counter.find({}, function(err, result) {         if (!(err)) {             res.render('index', {'lol' : result});         }     }); }); 

i'm trying app display contents of whole database , came with. counter mongoose model. database contains items inserted prior execution of program , 1 item inserted in app itself.

something iffy conceptually me (i'm new node), think render() being executed before find() why i'm not getting result, can't think of solution. or push in right direction appreciated. :)

what view code?

your implementation correct, should try debug.

server.get('/', function(req, res) {   counter.find({}, function(err, result) {     if (!(err)) {         console.log('debug: ' + json.stringify(result) );         res.render('index', {lol : result});     }   }); }); 

Comments

Popular posts from this blog

node.js - StackOverflow API not returning JSON -

python - Subclassed QStyledItemDelegate ignores Stylesheet -

sql server - TFS 2012 TF255062 Error after removing 'Active Directory' Role -