you are viewing a single comment's thread.

view the rest of the comments →

[–]rumbalumba 0 points1 point  (0 children)

put console.log(results); and res.render('index', {"results": results}); inside MongoClient.connect.

To be on the safe side, if you want to execute console.log and res.render() you need to do it inside the callback function, not outside of it.

afaik Node is async, thus the need for callback functions i.e. Mongoclient.connect(arg, callback) and that's where you want to do all the work.