const MongoClient = require("mongodb").MongoClient;
const assert = require("assert");
const url = "mongodb://localhost:27017";
const dbName = "fruitsDB";
const client = new MongoClient(url, { useNewUrlParser: true });
client.connect(function (err) {
assert.equal(null, err);
console.log("connected to the server");
const db = client.db(dbName);
client.close();
});
This code should show in the terminal "connected to the server."