Reputation: 11
I am new to nodejs and mongodb. As you see below code, I am trying to connect mongodb by NodeJs but there is an
"undefined" error
var mongoose = require('mongoose');
mongoose.Promise = require('bluebird');
var mongodb = 'mongodb://localhost/yenidb';
mongoose.connect(mongodb,{useMongoClient: true},function(err,err){
if(err){
console.log("mongoose error:" + err.log);
}
else{
console.log("mongoose db connection status :" + mongodb)
}
})
Upvotes: 1
Views: 50
Reputation: 3111
You are declaring 2 different variables with the same name. Declare them with diffrent names:
,function(err,err)
for example:
,function(err,connection)
Upvotes: 4