Friday 9 June 2017

MongoClient.connect error in node.js


Now I am trying to get the data from MongoDB in node.js.
I am using MongoClient for connection. But I failed.
Here is my code.

var connect_uri = "mongodb://carinventory:MongodbPassword@example.com:10250/?ssl=true";
MongoClient.connect(connect_uri, function (err, db) {
    if (err) throw err;
    console.log(db);
});

It is connecting to the server, but are getting empty data.

I tested with connecting URI above in MongoBooster and PHP MongoClient.
They are getting correct data from "carinventory" database.

What is wrong? I hope your kindly opinion.
Thank you.



via Jumping

No comments:

Post a Comment