Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // using $.getJSON('/list', function(data){do stuff with data})
- app.get('/list', function(req, res) {
- var items = getList();
- console.log('--- APP GET ---');
- console.log(items);
- res.json(items);
- });
- // had it before as res.json(getList()); but that didn't work either
- function getList(){
- MongoClient.connect('mongodb://heroku:thinkfast@dogen.mongohq.com:10042/reservations', function(err, db){
- if(err){
- return console.error(err);
- }
- var collection = db.collection('requests');
- collection.find({}).toArray(function (err, items){
- if (err) {
- return console.error(err);
- }
- console.log(items);
- return items;
- });
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement