How to remove "current URL string parser is deprecated" warning in Mongoose with TypeScript
Hello everyone! I'm writing a backend on Express with TypeScript and using MongoDB through Mongoose. When connecting to the database, I get this warning in the console:\n\n```\n(node:12345) DeprecationWarning: current URL string parser is deprecated, and will be removed in a future version. To use the new parser, pass option { useNewUrlParser: true } to MongoClient.connect.\n```\n\nI already tried adding `useNewUrlParser: true` in options, but I still see this message. Here's my code:\n\n```typescript\nimport mongoose from 'mongoose';\nimport { config } from './config';\n\nconst connectDB = async (): Promise => {\n try {\n await mongoose.connect(config.mongoURI, {\n useNewUrlParser: true,\n useUnifiedTopology: true,\n });\n console.log('MongoDB connected successfully');\n }
No answers yet.
Log in to leave an answer