Avoid “current URL string parser is deprecated” warning by setting useNewUrlParser to true
(node:4833) 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.
When making a server using Mongo, I faced this error message.
It seems like the current style will be deprecated soon. Well, for now the workaround is to pass { useNewUrlParser: true }
as a second parameter in the MongoCient.connect method.
And MongoCient.connect looks like below
MongoCient.connect( `mongodb url`, { useNewUrlParser: true }, (err, client) => { if (err) return console.error(err); db = client.db("quotes"); // if the connection is established with the database only, start my server. app.listen(3000, () => console.log("listening...")); } );