I would like to call several times my api and then return only my object in errors (here it's workers)
What do you think about this implementation? (I don't like the .then(()=> false
but I didn't figure out better implementation even with reduce)
I would like to avoid to filter after the Promise.all
Thanks
updateWorkersStatusOnMissions: (workersOnMissions, apiService) => {
const updateWorkerStatusOnMissionPromises = workersOnMissions
.map(workerOnMission =>
apiService.put('missions', formatWorkerOnMission(workerOnMission))
.then(() => false)
.catch(() => formatWorkerInError(workerOnMission))
)
return Promise
.all(updateWorkerStatusOnMissionPromises)
.then(filter(Boolean))
},