MongoDB and Mongoose - Install and Set Up Mongoose

I am having a trouble with crash loop in setting up my mongodb.
Describe your issue in detail here.
I am using replit and I do not know what causes the crash loop when running the program.

Your code so far
require(‘dotenv’).config();
const mongoose = require(‘mongoose’);
const mySecret = process.env[‘MONGO_URI’];
mongoose.connect(process.env.MONGO_URI, { useNewUrlParser: true, useUnifiedTopology: true });

Your browser information:

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

Challenge: MongoDB and Mongoose - Install and Set Up Mongoose

Link to the challenge:

remove the line const mySecret = process.env[‘MONGO_URI’];
cause you do not need it and also do not quote your database address when you are setting up the env variable

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