I’ve looked through several similar issues with the third MongoDB and mongoose challenge for FreeCodeCamp’s backend certification, but even when I try using other people’s glitch.com project links, I get the same ‘item.name’ must be a string error.
As it is, everytime I link to my project page and attempt to complete the challenge it says “item.name” should be a String.
I’ve tried re-writing my code several times, and have even looked up code that other people say passes the challenge, but the same error shows.
const createAndSavePerson = function(done) {
console.log('connection state to create and save:', mongoose.connection.readyState);
const Kurt = new Person(
{
name: "Kurt",
age: 32,
favoriteFoods: [ 'Cheese', 'Bread' ]
}
)
Kurt.save( (err, data, done) => {
if (err) {
console.log(err)
return done(err)
}
console.log(`${data} saved to collection`)
return done(null, data)
})
}
Thanks!