MongoDB and Mongoose - Install and Set Up Mongoose Problem

Hi, i’m having a problem with the first challenge of this lesson. I have already done everything but y still get this message.

This is my code so far:




And this is the config of the IP Whitelist in Atlas

I would appreciate very much any help.

how come you didnt use the mongo_url in your .env file?

Because i was searching the problem, but it makes no difference, i get the same result if i use the MONGO_URI

Because I can’t give you a hint in any way to help, I’ll just say if you use MONGO_URI you have to delete everything after the question mark.

If you don’t use that you need the question mark at the end of your connection.

I’ve answered this before and I’ll add I don’t know why the query makes it not work, but it doesn’t work with the query after the question mark.

I just checked that, but i still can’t connect Mongoose to the database.

Also never use quotes in the .env file.

If i take the quotes i get this error in the glich console:

Any ideas?

With the little code of yours that I see, it’s a little hard to say. But the directions say " Connect to the database using mongoose.connect()".

The directions don’t say to use a variable.

I reinstalled all the dependencies and it no longer shows me the error, but I still fail the test.

Did you stop using the variable? Also, you can include a callback function to log an error or log you are connected. Like

... {useNewUrlParser: true},
  function(err) {
    if (err) { console.log(err); }
    else { console.log("Connected to db!") };

Then you will see the error or “Connected to db!” in your log.