I have written a function that is being called in a loop (map) and that function is using promises. Now, I want that function to run synchronously and exit before its next i
(function loop(index) { const next = promiseArray[index]; if (!next) { return; } next.then((response) => { // do Something before next loop(index + 1); }).catch(e => { console.error(e); loop(index + 1); }); })(0 /* startIndex */)