MongoDB and Mongoose - Install and Set Up Mongoose

hello , please i need your help i don’t know how to connect on mongodb
i use replit ,in my myapp.js file I don’t know where exactly I’m going to put this mongoose.connect(, { useNewUrlParser: true, useUnifiedTopology: true }); and moreover I can not make my uri
see the link // boilerplate-mongomongoose - Replit

thank you

const mongoose = require(“mongoose”);
mongoose.connect(process.env[‘MONGO_URI’], { useNewUrlParser: true, useUnifiedTopology: true });

see the code I can’t connect to mongodb

You still don’t appear to have added this line of code to your repl.
You won’t be able to connect until you do.
Have you stored your MONGO_URI in your Secrets tab?

key: mongo_uri

That’s not a MongoDB uri. You need to follow the setup instructions (which are linked in the challenge description), to setup a connection with an external database cluster and get a uri which you can use to interact with it.

mongoose.connect(<Your URI>, { useNewUrlParser: true, useUnifiedTopology: true});

please where am i supposed to see my uri?

Do you still need help? Have you followed the setup instructions for connecting with MongoDB Atlas?

@borel Please do not create duplicate threads for the same challenge. If you need help with this challenge please keep it to this thread.

I would suggest you read the documentation provided in the article and/or look at the docs for the sites and libraries you are using.

this is my code i don’t know why is not working//

let mongoose = require(“mongoose”);
mongoose.connect(process.env.MONGO_URI, { useNewUrlParser: true, useUnifiedTopology: true });

Have you followed the MongoDB setup guide I linked above (which is also linked in the challenge description)?
This will setup your connection to the external database and give you a URI which you can store in your Secrets tab.

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