MongoDB and Mongoose - Create a Model

Tell us what’s happening:

My solution of " MongoDB and Mongoose - Create a Model" challenge is getting this [Error: Cannot read properties of undefines ( reading ‘modelName’)]

const mongoose = require("mongoose");
mongoose.connect(process.env.MONGO_URI_TEST, {
  useNewUrlParser: true,
  useUnifiedTopology: true,
});
const personSchema = new mongoose.Schema({
  name: {
    type: String,
    required: true,
  },
  age: Number,
  favoriteFoods: [String],
});
let Person = mongoose.model("Person", personSchema);

###Your project link(s)

solution: https://fg89v8-3000.csb.app

Your browser information:

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

Challenge Information:

MongoDB and Mongoose - Create a Model

We can’t see all your code, please link to the editor.

My best guess is, you have removed the export at the bottom of the file. Person should be exported so server.js can import it.

myApp.js

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

exports.PersonModel = Person;

server.js

const Person = require("./myApp.js").PersonModel;

router.use(function (req, res, next) {
  if (req.method !== "OPTIONS" && Person.modelName !== "Person") {
    return next({ message: "Person Model is not correct" });
  }
  next();
});