Skip to content

Instantly share code, notes, and snippets.

@keyserfaty
Last active September 27, 2018 22:25
Show Gist options
  • Save keyserfaty/73c80cdfb0adf047a37cd9e3f907ea01 to your computer and use it in GitHub Desktop.
Save keyserfaty/73c80cdfb0adf047a37cd9e3f907ea01 to your computer and use it in GitHub Desktop.
An example of a saga making multiple requests with unknown bodies
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