I am currently working with the following data structure:
product: {
id: "id1",
title: "ProductName 1",
additionalDetails: {
o1: {
id: "pp1",
label: "Text",
content: [{ id: "ppp1", label: "Tetetet" }]
},
o2: {
id: "pp2",
label: "Text2",
content: [{ id: "ppp2", label: "Tetetet2" }]
}
}
}
I have been attempting to iterate through each object inside `additionalDetails`, but for some reason, it is not working as expected. Here is my code snippet:
Object.keys(product.additionalDetails).forEach((key: string) => {
const additionalDetail = product[key];
const idLabel: string = additionalDetail.id;
const label: string = additionalDetail.label;
const contentId: string = additionalDetail.content[0].id;
const content = additionalDetail.content[1].label;
});
Unfortunately, this code snippet does not seem to be functioning correctly. Can anyone help point out what I might be missing or doing wrong?