I'm trying to add dynamically created objects inside an object, however it overrides the properties in each iteration in the forEach ... I would like to create an object equal to the image with the GREEN color, the RED color is what it is returning to me now..
NOTE: I do not want to create an array, but instead create keys and values ​​dynamically and add in the given object to insert into a SET afterwards.
static organizeData(){
let organizedData = {};
let oi = {
"NAME1": {},
"NAME2": {}
}
console.log(oi)
API.data.records.forEach(record => {
record.INDICADORES.forEach(indicadores => {
if(indicadores.tipo === API.queryIndicatorType){
indicadores[indicadores.tipo].KPIS.forEach(kpi => {
organizedData = { [kpi.tipo]: kpi[kpi.tipo] }
});
}
});
});
API.organizedData = organizedData;
console.log(organizedData)
}