rudamentary mutli-post err handling

This commit is contained in:
Alexander Wong
2018-04-22 16:39:17 -06:00
parent 530593b721
commit dac6daa933
9 changed files with 194 additions and 21 deletions

19
src/api/cShift.api.js Normal file
View File

@@ -0,0 +1,19 @@
import { post } from "./baseApi";
export function createCShifts(postBodies) {
const cShiftUrl = `/cshift/`;
// return Promise.all(
// postBodies.map(postBody => post(cShiftUrl, postBody).catch(() => false))
// ).then(postResponses => {
// Promise.resolve(postResponses);
// });
return Promise.all(
postBodies.map(postBody =>
post(cShiftUrl, postBody).catch(err => {
return { error: true, ...err };
})
)
).then(resp => {
return Promise.resolve(resp);
});
}