I'm trying to create a web page that will pull data from MongoDB server.
I tried to use node js driver, but it regularly throwing this error:
this is my mongo.js script:
require(['mongodb'], function(mongodb) {
mongodb.MongoClient.connect("mongodb://x.x.x.x:27017", function (err, client) {
console.log("Connected successfully to server");
});
});
The method connect
is not working for me (it throws the error).
I tried to connect in a many different ways.
I placed it in the bottom of the html body.
How can I solve this problem?
Thanks!