The server gives the following response:
SomeObject:{
Object1:{
id: 123456789,
name: "Foo"
},
Object2:{
id: 123456789,
name: "Bar"
}
}
Is it possible to loop over SomeObject and display both the id and name of Object1/Object2? Searching for this mostly lead to using Object.keys(SomeObject).map however those are use to get the string of Object1/Object2.
>Solution :
const SomeObject = { Object1: { id: 123456789, name: "Foo" }, Object2:{ id: 123456789, name: "Bar" } };
const res =
Object.values(SomeObject)
.forEach(({ id, name }) => console.log(id, name));