2

I am trying to find whether my cart is empty by using const isEmpty = !cart.line_items.length;, but it is returning Cannot read property length of undefined. So i console.logged whether cart.line_items is an array and it ends up returning false, true, true. So for some reason it isnt recognized as an array at the start. How would I fix this?

Arxci
  • 95
  • 1
  • 7

1 Answers1

1

Adding this catch if(!cart.line_items) return 'Loading...' seemed to solve the problem

Arxci
  • 95
  • 1
  • 7