Friday, 12 May 2017

Can't connect to a MongoDB using Node.js

Can't connect to a MongoDB using Node.js.

This is my code (mdb.js):

var MongoClient = require('mongodb').MongoClient, format = require('util').format;

MongoClient.connect('mongodb://localhost:3000', function(err,db){

    if(err){
         throw err;
    } else {
         console.log("Connected");
    }
    db.close();
});

node mdb.js prints MongoError:

enter image description here



via smus

No comments:

Post a Comment