get a list of the properties of the object react native

Since the object you want in the output is nested, you’ll need to loop over two levels in your JSON:

let input = [
  {
    "-ML8Lx8jOSv64Ecat611": {
      "category": "Automotive Parts & Accessories",
      "description": "I will be there at least but I don't know if I can help in any way I can",
      "item": "Apple Watch",
      "price": "429,99",
      "timestamp": "2020-11-02T21:28:11+07:00",
      "viewCount": 0
    }
  }
];

let result = []
input.forEach(obj => {
  Object.keys(obj).forEach(key => {
    result.push(obj[key]);
  });
});

console.log(result);

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top