Hi guys
Today I am stucked at this challange. I can’t figure out what I did wrong. I just followed what the hints say.
Here is the code:
const mongoose = require("mongoose");
mongoose.connect("mongodb+srv://trica:cipolla@cluster0.ubh7l.mongodb.net/trica?retryWrites=true&w=majority", { useNewUrlParser: true, useUnifiedTopology: true });
console.log(process.env.MONGO_URI);
// here I create the Schema
const Schema = mongoose.Schema;
const personSchema = new Schema({
name: { type: String, required: true },
age: Number,
favoriteFoods: [String]
});
//create the model
var Person = mongoose.model("Person", personSchema);
//create and save a record
var createAndSavePerson = function(done) {
var roughDoor = new Person({
name: "Rough Door",
age: 2,
favoriteFoods: ["meat", "meat again"]
});
roughDoor.save(function(err, data) {
if (err) return done.error(err);
done(null, data);
});
};
FCC output:
// running tests
Creating and saving a db item should succeed
// tests completed
glitch project here:
What do you think I did wrong?
after I hit the button "Complete this challange " on Glitch console it says Missing done() argument. I tried to call the function createAndSavePerson and the Glitch console says “error not Handled”. I tried a Try-catch but it does the same. I looked up in internet but I found nothing.