I am using mongoose to connect the MongoDB with my backend.
const connectDB = async () => { try { const conn = await mongoose.connect(process.env.MONGO_URI, { useNewUrlParser: true, useUnifiedTopology: true, });
This is the piece of code I wrote and it has 2 warning: "Warning: useNewUrlParser is a deprecated option" and "Warning: useUnifiedTopology is a deprecated option". Is there a way to fix them?
I tried installing version <4.0 but same error is picking up.
2
Answers
Simply remove it. Your code should look like this
The problem can be resolved by updating the MongoDB connection setup in Mongoose to use the latest default settings. Simply connect without specifying any additional options:
#mdmahfuzrp #mahfuzrp #mrp