MongoDB and Mongoose - Create a Model: Closing Connection

I’m working through the MongoDB and Mongoose Challenges and managed to get my code to run, but the FCC tests keep failing and the webview only shows this:

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);
let brandon = function(done) {
  return new Person({
  name: "Brandon",
  age: 24,
  favoriteFoods: ["Pizza", "Ice Cream", "White chocolate"]
if(error) return done(error);

If it helps, this is the link to my

Create a file .env and then add this bit MONGO_URI.

Currently process.env.MONGO_URI returns undefined.

MongooseError: The `uri` parameter to `openUri()` 
must be a string, got "undefined". 
Make sure the first parameter to `mongoose.connect()` or 
`mongoose.createConnection()` is a string.

This is from your logs.

Follow the instructions from the challenge and you should be fine.

1 Like

Welcome, brandonmbest. were down for a while (I am not sure since when). I have been able to get my projects back up and running. So, it might be worth just giving it another try.