MongoDB and Mongoose - Install and Set Up Mongoose

Tell us what’s happening:
I am having a problem connecting to my database (using Glitch):
I will add my code to see if that can help you help me:
.env fil:
I have added a variable MONGO_URI to that file (using the Glitch method for doing this) with a value: ‘mongodb+srv://MongoGerry:@cluster0.uawkdwq.mongodb.net/fcc-mongodb-and-mongoose?retryWrites=true&w=majority’

package.json:
{
“name”: “fcc-mongo-mongoose-challenges”,
“version”: “0.0.1”,
“description”: “A boilerplate project”,
“main”: “server.js”,
“scripts”: {
“start”: “node server.js”
},
“dependencies”: {
“body-parser”: “^1.15.2”,
“dotenv”: “^8.2.0”,
“express”: “^4.12.4”,
“mongoose”: “^5.11.15”
},
“repository”: {
“type”: “git”,
“url”: “GitHub - freeCodeCamp/boilerplate-mongomongoose: A boilerplate for the freeCodeCamp curriculum.
},
“keywords”: [
“node”,
“mongoose”,
“express”
],
“license”: “MIT”
}

myApp.js:

require(‘dotenv’).config();
const mongoose=require(‘mongoose’);
mongoose.connect(‘mongodb+srv://MongoGerry:@cluster0.uawkdwq.mongodb.net/fcc-mongodb-and-mongoose?retryWrites=true&w=majority’
, { useNewUrlParser: true, useUnifiedTopology: true });
/mongoose.connect(process.env.‘mongodb+srv://MongoGerry:@cluster0.uawkdwq.mongodb.net/fcc-mongodb-and-mongoose?retryWrites=true&w=majority’
);
/

let Person;

const createAndSavePerson = (done) => {
done(null /, data/);
};

const createManyPeople = (arrayOfPeople, done) => {
done(null /, data/);
};

const findPeopleByName = (personName, done) => {
done(null /, data/);
};

const findOneByFood = (food, done) => {
done(null /, data/);
};

const findPersonById = (personId, done) => {
done(null /, data/);
};

const findEditThenSave = (personId, done) => {
const foodToAdd = “hamburger”;

done(null /, data/);
};

const findAndUpdate = (personName, done) => {
const ageToSet = 20;

done(null /, data/);
};

const removeById = (personId, done) => {
done(null /, data/);
};

const removeManyPeople = (done) => {
const nameToRemove = “Mary”;

done(null /, data/);
};

const queryChain = (done) => {
const foodToSearch = “burrito”;

done(null /, data/);
};

/** Well Done !!
/* You completed these challenges, let’s go celebrate !
*/

//----- DO NOT EDIT BELOW THIS LINE ----------------------------------

exports.PersonModel = Person;
exports.createAndSavePerson = createAndSavePerson;
exports.findPeopleByName = findPeopleByName;
exports.findOneByFood = findOneByFood;
exports.findPersonById = findPersonById;
exports.findEditThenSave = findEditThenSave;
exports.findAndUpdate = findAndUpdate;
exports.createManyPeople = createManyPeople;
exports.removeById = removeById;
exports.removeManyPeople = removeManyPeople;
exports.queryChain = queryChain;

Your project link(s)

https://troubled-literate-capri.glitch.me/

Your browser information:

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

Challenge: MongoDB and Mongoose - Install and Set Up Mongoose

Link to the challenge:

You appear to missing the username’s password that would be after MongoGerry: and before cluster0.

In your Glitch code, you have the password in brackets <> which I’m guessing isn’t how you made the password. The brackets are just symbols used in the docs for placeholders.

So it should be YourPassword not <YourPassword>


You should really use the .env file so you do not leak your connection string. I would create a new password after you have removed it from your code.

https://glitch.com/edit/#!/troubled-literate-capri?path=myApp.js