Javascript – Wait until all subpromises are resolved
Let's say I have something like: const exampleFunction = () => { const fetchActions = someArray.map(() => { dispatch(action()).then(response => { if (response?.data) { dispatch(subAction({response: response.data})) } }) }) return Promise.all(fetchActions) .then(()=> dispatch(finalAction())) } My problem is that when I…