Tell us what’s happening:
When trying to start the connection with the Mongo db I continuously get this error message:
(node:1365) [DEP0170] DeprecationWarning: The URL mongodb://user:password@ac-c0tkbpu-shard-00-00.8qlweyy.mongodb.net:27017,ac-c0tkbpu-shard-00-01.8qlweyy.mongodb.net:27017,ac-c0tkbpu-shard-00-02.8qlweyy.mongodb.net:27017/?authSource=admin&replicaSet=atlas-j472zl-shard-0&retryWrites=true&w=majority&appName=Cluster0&ssl=true is invalid. Future versions of Node.js will throw an error.
(obviously in the 'real 'version of this message user and password are my username and password).
I have done the folowing:
-
created the .env file and pasted the connect string provided by Mongodb to a var called MONGO_URI
MONGO_URI=“mongodb+srv://user:password@cluster0.8qlweyy.mongodb.net/?retryWrites=true&w=majority&appName=Cluster0”
(again, user and password are of course filled in). -
created the mongoose variable:
const mongoose = require(‘mongoose’); -
tried to connect mongoose to the Mongodb database:
mongoose.connect(process.env.MONGO_URI, { useNewUrlParser: true, useUnifiedTopology: true })
The result is the error message given above.
No idea what to do here.
Your code so far
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:123.0) Gecko/20100101 Firefox/123.0
Challenge Information:
MongoDB and Mongoose - Install and Set Up Mongoose