Hello there,
Just to mention it for reduced confusion: The freeCodeCamp tests delete the records in your database after adding them. From what I can see, there should be no documents left in your database, unless you manually added them:
const createPeople = require("./myApp.js").createManyPeople;
router.post("/create-many-people", function (req, res, next) {
Person.remove({}, function (err) {
if (err) {
return next(err);
}
// in case of incorrect function use wait timeout then respond
let t = setTimeout(() => {
next({ message: "timeout" });
}, TIMEOUT);
createPeople(req.body, function (err, data) {
clearTimeout(t);
if (err) {
return next(err);
}
if (!data) {
console.log("Missing `done()` argument");
return next({ message: "Missing callback argument" });
}
Person.find({}, function (err, pers) {
if (err) {
return next(err);
}
res.json(pers);
Person.remove().exec();
});
});
});
});
Hope this helps