Answers for "client.connect is not a function node js mongodb"

0

mongodb.connect is not a function

const { MongoClient } = require("mongodb");

const uri = "yourUri...";
const databaseName = "yourDBName";

MongoClient.connect(uri, { useNewUrlParser: true }, (error, client) => {
  if (error) {
    return console.log("Connection failed for some reason");
  }
  console.log("Connection established - All well");
  const db = client.db(databaseName);
});
Posted by: Guest on August-09-2021
0

client.connect is not a function node js mongodb

//Just add this line of code and client.connect and 
//-other dot functions will work

var mongo = require('mongodb').MongoClient;
Posted by: Guest on March-19-2021

Code answers related to "client.connect is not a function node js mongodb"

Code answers related to "Javascript"

Browse Popular Code Answers by Language