Tell us what’s happening:
I have been trying for hours, read through all the forums and I still can’t seem to understand what’s wrong with it.
It kept on giving me the error:
-
- “mongoose” should be connected to a database
This are my codes:
.env
MONGO_URI=‘mongodb+srv://weird:Lm9fHhgjz6hquPA6@cluster0.bghfh.mongodb.net/apple?retryWrites=true&w=majority&appName=Cluster0’
myApp.js
const mongoose = require(‘mongoose’);
mongoose.connect(process.env.MONGO_URI, { useNewUrlParser: true, useUnifiedTopology: true });
package.json
“dependencies”: {
“body-parser”: “^1.15.2”,
“dotenv”: “^8.2.0”,
“express”: “^4.12.4”,
###Your project link(s)
solution: https://3000-freecodecam-boilerplate-reu387950mk.ws-us117.gitpod.io
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/132.0.0.0 Safari/537.36
Challenge Information:
MongoDB and Mongoose - Install and Set Up Mongoose