DEV Community

Sanket N Jain
Sanket N Jain

Posted on

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)