rudamentary mutli-post err handling
This commit is contained in:
19
src/api/cShift.api.js
Normal file
19
src/api/cShift.api.js
Normal 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);
|
||||
});
|
||||
}
|
Reference in New Issue
Block a user