I am getting an error when i run my application.
The error:
MongoDB.on('error', function(err) { console.log(err.message); });
TypeError: Cannot read property 'on' of undefined
...
I tried to comment that part of the code out to see if i have anymore similar errors and found another same one. ( This time the word "once" )
The code:
var mongoURI = "mongodb://localhost/chatapp";
var MongoDB = mongoose.connect(mongoURI).connection;
MongoDB.on('error', function(err) { console.log(err.message); });
MongoDB.once('open', function() {
console.log("mongodb connection open");
});
It would be really great if anyone could help me solve this :( I searched the internet and found nothing helpful.