In nodejs the findIndex is undefined
let userCart = db.get().collection(collection.CART_COLLECTION).findOne({user:objectId(userId)})
if (userCart){
let proExist=userCart.products.findIndex(product=> product.item==proId)
console.log(proExist);
}
in my console it says:
UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'findIndex' of undefined
at C:\Users\Toshiba\Desktop\Projects\E-Commerce Application\helpers\user-helper.js:49:48
at new Promise (<anonymous>)
at Object.addToCart (C:\Users\Toshiba\Desktop\Projects\E-Commerce Application\helpers\user-helper.js:46:16)