As i'm new to api creation in nodejs and i tried to connect mongo db throung nodejs code and i have advance version of mongodb(V4) and nodejs(v10) and i could not able to connect please can any one help me.
my mongodb node code:
// Retrieve
var MongoClient = require('mongodb').MongoClient;
// Connect to the db
MongoClient.connect("mongodb://localhost:27017/exampleDb", function(err, db) {
if(!err) {
console.log("We are connected");
}
});
and cmd: commend for db connection in cmd prompt is mongod -- for connection establishement.