How can I yield inside a foreach or map? I found this (https://github.com/redux-saga/redux-saga/issues/306) GitHub question. But what I need is I want to make multiple post requests to a single API endpoint.
According to the mentioned github question I came up with this. But I'm confused on how can I catch any error, store it somewhere (even the groupId) and continue with the next request in the loop
function* createGroups(data) {
const task = yield fork(Api.createGroupUrl,, data);
// How can I catch the particular error and continue ?
}
yield payload.rateGroups.map(group =>
call(createGroups, { ...requestData, groupId: group.id }),
);
Let's say I need to do 5 API requests. If 2nd one fails I want to continue the 3rd request by storing that 2nd one failed. So, in the end, 2nd and 4th requests might have failed but 1,3,5 might have been successful. I need to know which requests were failed at the end of the loop. How can I do this? Any help would be appreciated. Thanks