0

I created a class "basketContent" with two properties (idCamera and lenses) which each have values. I can get several instance of this class. Now I would like to get the value of all the idCamera of each instance. I tried with this, but it's not working for now.

 basketContent = localStorage.getItem("basketContent");
    console.log(basketContent);

    for(idCamera in basketContent){ 
          let itemCamera = cameras.find(cameras => cameras['_id'] == idCamera);
          console.log(itemCamera);
    }
mplungjan
  • 169,008
  • 28
  • 173
  • 236

1 Answers1

0

try this

basketContent = JSON.parse(localStorage.getItem("basketContent")) || {};
console.log(basketContent);

for(idCamera in basketContent){ 
      let itemCamera = cameras.find(cameras => cameras['_id'] == idCamera);
      console.log(itemCamera);
}
Sheelpriy
  • 1,675
  • 17
  • 28