In the code section is a typical JSON object I am getting back
Was wondering what is the best way to loop in NodeJS, lint for some reason doesn’t like me using for (let item of myArray) it complains about 'ForOfStatement' is not allowed.
My current output comes out as the following:
Cont { id: 'Something1', mycontent: { foo: '1', bar: '1' } }
Cont { id: 'Something2', mycontent: { foo: '3', bar: '7' } }
so losing some of my values which I am assuming is due to me using Object.Entries as its key value pairs, whats the best way to loop round and retain these keys?
myObject = [{
"id": "Something1",
"mycontent": [{
"foo": "12",
"foo": "1",
"bar": "1"
}]
},
{
"id": "Something2",
"mycontent": [{
"foo": "3",
"bar": "5",
"bar": "7"
}]
}
]
Object.entries(myObject).forEach((item) => {
let myContent = item[1];
console.log("Cont", myContent);
});
I expect the output of my object appear as:
Something 1: foo: 12, 1 : bar 1; Something2 : foo: 3, bar: 5, 7
As I have duplicated keys weren't sure how to output these