MongoDB Create a Model Challenge not passing

Was an issue with the mySecret. Replit inserts it into the code like below, but just needs to be process.env.MONGO_URI. Annoying little time waster!

Trying to pass this challenge and nothing seems to work. Even just copied the code from the hint in and still won’t pass. Doesn’t give any helpful message to look for either. Using replit

const mongoose = require('mongoose');
const mySecret = process.env['MONGO_URI'];

mongoose.connect(mySecret, { useNewUrlParser: true, useUnifiedTopology: true });

const Schema = mongoose.Schema;

const personSchema = new Schema({
  name: { type: String, required: true },
  age: Number,
  favoriteFoods: [String]
});

const Person = mongoose.model("Person", personSchema);

Your browser information:

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

Challenge: Create a Model

Link to the challenge:

Did you setup your .env variables in replit for mySecret?

1 Like