Post any code you think might be relevant (one fenced block per file)
router.patch('/intake/:profileId/:intakeId', removeBlanks, (req, res, next) => {
Profile.findById(req.params.profileId)
.then(handle404)
.then(profile => {
// find the individual comment
console.log('this is profile', profile)
console.log('this is intake id', req.params.intakeId)
const nutrients = profile.nutrition.id(req.params.intakeId)
// get the new comment from req.body
const newNutrition = req.body.nutrition
// update the old comment
nutrients.body = newNutrition.body
// can't do it the way below because it is a model method and comments are only a schema
// comment.updateOne(newComment)
// save the place
return profile.save()
})
.then(() => res.sendStatus(204))
.catch(next)
})
If you see an error message, post it here. If you don't, what unexpected behavior are you seeing?
TypeError: profile.nutrition.id is not a function
What is your best guess as to the source of the problem?
something is wrong with the things i am retrieving from the promise chain
What things have you already tried to solve the problem?
What stack are you using?
(ex: MERN(mongoose + react), DR(django + react), PEN, etc.)
MERN
What's the problem you're trying to solve?
Patch route won't work
Post any code you think might be relevant (one fenced block per file)
If you see an error message, post it here. If you don't, what unexpected behavior are you seeing?
TypeError: profile.nutrition.id is not a function
What is your best guess as to the source of the problem?
something is wrong with the things i am retrieving from the promise chain
What things have you already tried to solve the problem?
Many things i can't count