In the nested loops I have async await. For me it is important that on each iteration loop will wait until await will be finished/data received and the start next iteration.
const _sampleFilters = async (
pageName,
details,
available,
) => {
for (const filterName of Object.keys(details)) {
for (const filterValue of Object.keys(details[filterName])) {
const data = (await fetchDetails(
pageName
));
details[filterName][filterValue].allDetails = cloneDeep(
getProcessedData(
data.map(data => data.value),
available,
pageName,
),
);
}
}
};