Tell us what’s happening:
Greetings,
before you ask, yes, I’ve already searched all over the forums and internet in hope to figure out why my code is not working, I’ve triple checked everything and it’s still not letting me pass the challenge. I’m smashing my head over this challenge for a week now… Mongo URI is correct and I can connect to it with Compass without any problems.
Your code so far
const mongoose = require('mongoose');
mongoose.connect(process.env.MONGO_URI, { useNewUrlParser: true, useUnifiedTopology: true });
var Schema = mongoose.Schema;
var personSchema = new Schema({
name: {
type: String,
required: true
},
age: Number,
favoriteFoods: [String]
});
var Person = mongoose.model('Person', personSchema);
Does the URI show? I assume you’re using Glitch and Glitch would just not accept the URI for me as an environment variable, and would keep returning undefined.
When I replaced it with my URI it passed the challenge, so the issue might be with your database access.
Have you allowed access from all IP addresses in MongoDB atlas?
Thanks a lot for help, it passed with that one now. A strange thing is that I used the first URL in the first challenge and it worked, but not with the second one.