project_e_commerce
project_e_commerce copied to clipboard
TypeError: Cannot read property 'length' of undefined
can you guys plz help me with this??
trying using it this way, i dont understand why .length does'nt work either.
const isEmpty = () => {
if (cart.line_items === 0) {
return true
} else {
return false
}
}
If stuck, just look for any response changes from the commerce API call. Here's how I solved it: {!cart.line_items ? ShowEmptyCart() : ShowFilledCart()} or {!cart.line_items ? <ShowEmptyCart /> : <ShowFilledCart />}
Happy Coding! ☺