DEV Community

Sanket N Jain
Sanket N Jain

Posted on

1 1

Caught an error while pushing a product to cart. TypeError: Cannot read property 'push' of undefined

I want to push the product details into the cart model when a user clicks on "add to cart" button on a particular product. But it shows TypeError: Cannot read property 'push' of undefined

Here is the route file:

router.post("/product/:id/addCart", isLoggedIn, function(req, res){
const quantity = req.body.quantity
Product.findById(req.params.id, function(err, foundProduct){

Top comments (0)

AWS Security LIVE!

Join us for AWS Security LIVE!

Discover the future of cloud security. Tune in live for trends, tips, and solutions from AWS and AWS Partners.

Learn More

👋 Kindness is contagious

If this article connected with you, consider tapping ❤️ or leaving a brief comment to share your thoughts!

Okay