I am new to node js. I am working on simple user authentication app.
I am unable to connect to mongodb cluster0, getting error:
(node:22264) DeprecationWarning: current Server Discovery and Monitoring engine is deprecated, and will be removed in a future version. To use the new Server Discover and Monitoring engine, pass option { useUnifiedTopology: true } to the MongoClient constructor. TypeError: callback is not a function at $initialConnection.$initialConnection.then.err
I have used both ways by adding this or not { useUnifiedTopology: true }
still
getting same error
const express = require("express");
const expressLayouts = require("express-ejs-layouts");
const mongoose = require("mongoose");
const app = express();
//DB config
const db = require("./config/keys").MongoURI;
//connect to mongodb
mongoose
.connect(db, { useNewUrlParser: true }, { useUnifiedTopology: true })
.then(() => console.log("MongoDB Connected"))
.catch(err => console.log(err));
My keys.js
module.exports = {
MongoURI:
"mongodb+srv://cluster0:<123455>@cluster0-7tt0p.mongodb.net/test?retryWrites=true&w=majority"
};