Tell us what’s happening:
Just keeping getting this error at the glitch log, I literally copied and pasted the solution after many attempts and still fails! I was really enjoying it so far.
Glitch:
(can’t post it because FCC won’t let me)
Error:
Your code so far
const mongoose = require("mongoose");
const { Schema, model } = mongoose;
try {
mongoose.connect(process.env.MONGO_URI, {
useNewUrlParser: true,
useUnifiedTopology: true
});
} catch (e) {
console.error(e);
}
var personSchema = new mongoose.Schema({
name: String,
age: Number,
favoriteFoods: [String]
});
var Person = mongoose.model("Person", personSchema);
var createAndSavePerson = function(done) {
var janeFonda = new Person({
name: "Jane Fonda",
age: 84,
favoriteFoods: ["vodka", "air"]
});
janeFonda.save(function(err, data) {
if (err) return console.error(err);
done(null, data);
});
};
exports.PersonModel = Person;
exports.createAndSavePerson = createAndSavePerson;
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:75.0) Gecko/20100101 Firefox/75.0
.
Challenge: MongoDB and Mongoose - Create and Save a Record of a Model
Link to the challenge: