Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reviews not getting push in to campground review array, getting property of review null error #33

Open
Sushmitha1703 opened this issue Nov 14, 2022 · 2 comments

Comments

@Sushmitha1703
Copy link

module.exports.create=async(req,res,next)=>{
const campgrounds= await campGround.findById(req.params.id)
const reviewsss= new reviews(req.body.review)
reviewsss.author= req.user._id
campgrounds.review.push('reviewsss')
console.log(campgrounds.review)
await reviewsss.save()
await campgrounds.save()
req.flash('success','review created')
res.redirect(/campground/${campgrounds._id})
}

@bowen-anth
Copy link

On line 2, you have 'campGround.findById(req.params.id)'. Maybe it's supposed to be 'Campground'?

@TalibIbrahim
Copy link

console.log the campground and the req.body. See if they show up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants