Поскольку топор ios вызывает возврат обещаний. Что вы можете сделать, так это дождаться выполнения всех обещаний.
let jobs: Promise<any>[] = [];
array.forEach(item => {
console.log("Loop started");
let id = [item.id];
let type = item.type;
if (subType == "a") {
const job = api.method(type, id)
.then(response => {
console.log("response.data :>> ", response.data);
})
.finally(() => {
console.log("finally item :>> ", item);
});
jobs.push(job);
} else if (subType == "b") {
const job = api.method(type, id)
.then(response => {
console.log("response.data :>> ", response.data);
})
.finally(() => {
console.log("finally item :>> ", item);
});
jobs.push(job)
}
});
await Promise.all(jobs);
// the code here will start to execute when all promises have been resolved.