I encountered an issue with my Javascript and mongoDB integration. I established the connection using:
var db = mongo.db(config.connectionString, { native_parser: true });
and linked my visitors collection db.bind('visitors');
. After that, I attempted to retrieve all documents from it with this line:
db.visitors.find(function (err, visitors) {
if (err) deferred.reject(err.name + ': ' + err.message);
deferred.resolve(visitors);
});
It appears everything is set up correctly from my end. However, I keep encountering this error every time:
angular.js:12011 GET http://localhost:3000/api/visitors/getAll 400 (Bad Request)
I initially thought it was an issue with my API, so I tried ...findOne({_id:1},..
and it worked. Did I overlook something here?