Last active
September 27, 2018 22:25
-
-
Save keyserfaty/73c80cdfb0adf047a37cd9e3f907ea01 to your computer and use it in GitHub Desktop.
An example of a saga making multiple requests with unknown bodies
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export function * fetchAllWorker (action) { | |
yield put(actions.fetchAll.start()) | |
const { types } = action.payload | |
for (let i = 0; i < types.length; i++) { | |
const { res, error } = yield call(get, `js_helpers/${types[i]}`) | |
if (res.status > 201 || error) { | |
return put(actions.fetchAll.failure({ error })) | |
} else { | |
yield put(actions.fetchAll.success({ items: res.data })) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment