Hello I have this function:
private _getServiceTask(tasks) {
let result:;
tasks.map(async (task, index) => {
if (index === 0) {
result = await callApi({
id: task.provider_id,
});
return;
}
if (index !== 0 && task.provider_id !== tasks[index - 1].provider_id) {
result = await callApi({
id: task.provider_id,
});
}
if (result) {
const { providers } = result;
providers?.map((provider) =>
task.settings?.push({
name_translations: provider.name_translations,
description_translations: provider.description_translations,
})
);
}
});
}
I would like to assign result a value and keep it until a condition is matched in .map function and result is reassigned to another value.
My issue is that in the first loop, result has value, and then is undefined. Anyone knows what I'm doing wrong?