How I can iterate a nested object to acces to their values in React Js

  javascript, loops, nested, object, reactjs

I’ve searched a lot for this and I don’t get a suitable answer to solve this. I have an object that I’ve made from a fetched data and the structure is like this:

{
      id: string,
      title: string,
      price: {
        currency: string,
        amount: number,
      },
      picture: string,
      condition: string,
      free_shipping: string,
      sold_quantity: string,
    };

When I try to iterate through the nested object (second level)

price: {
        currency: string,
        amount: number,
      },

console throws an error to undefined. I’ve tried: Object.keys() method or transform the object into an array without success.

Does anyone know how I can iterate through this object and obtain the values of each property: currency, amount

Thanks in advance for your help.

Source: Ask Javascript Questions

LEAVE A COMMENT