Tell us what’s happening:
Doing the Challenge via Gitpod.
dependencies:
.env file:
MONGO_URI='mongodb+srv://<myusername>:<mypassword>@cluster0.d3v9l.mongodb.net/?retryWrites=true&w=majority&appName=Cluster0'
myApp.js
const mongoose = require('mongoose');
mongoose.connect(process.env.MONGO_URI, {
useNewUrlParser: true,
useUnifiedTopology: true,
}).then(() => {
console.log("MongoDB connection successful");
console.log("Mongoose connection state:", mongoose.connection.readyState);
}).catch((err) => {
console.error("MongoDB connection error:", err);
});
Terminal:
MongoDB connection successful
Mongoose connection state: 1
The Mongodb-site also shows in and output from/to my DB. So i feel like the connection is successful especially as it took a while to get the terminal logs to show a successful connection/a 1 there and that changing correlates with in-/output appearing on the mongodb-site. But test2
// running tests
2. “mongoose” should be connected to a database
// tests completed
is not fullfiled. Solution Link worked fine for all previous gitpod challenges.
Anything obvious i’m missing? Thanks for your help.
###Your project link(s)
solution: http://localhost:3000
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36
Challenge Information:
MongoDB and Mongoose - Install and Set Up Mongoose