MongoDB and Mongoose - Install and Set Up Mongoose

I am not sure why is this not working.
I might be having issue in connecting it to the database but even if that’s the problem why am I not passing package.json test case
Describe your issue in detail here.

Your project link(s)

solution: Glitch :・゚✧

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36

Challenge: MongoDB and Mongoose - Install and Set Up Mongoose

Link to the challenge:

mongoose.connect(process.env.MONGO_URI);

This is not the correct syntax. The challenge specifies exactly what is required. You’re missing something.

OK, so now this is what happens

You should have your MONGO_URI stored in your .env file. DO NOT include it in your publicly visible code.

The format of the URI should be similar to this:
mongodb+srv://<username>:<password>@<cluster-name>.prx1c.mongodb.net/<db-name>?retryWrites=true&w=majority

You should only need to insert your password, as all other fields should already be filled in for you.

NOTE: If your password contains any of these special characters, you will need to use percent encoding: : / ? # [ ] @

Thanks a ton, was stuck on this for hours.

Is it your replit sign in password?

No, you need to follow the instructions which are linked in the challenge description:

These instructions will help you to set up a MongDB Atlas account with a unique username and password which you can then use to create your URI, to be used to connect to your database cluster from repl (or elsewhere).

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.