rsnext/examples/with-apollo-and-redux-saga/lib/placeholder/sagas.js
Corbin Crutchley 1d66da15a1 with apollo and redux saga example: Update deps (#6734)
* with apollo and redux saga example: Update deps

* Fix linting problems
2019-03-27 16:00:57 -05:00

19 lines
521 B
JavaScript

import { put, takeLatest } from 'redux-saga/effects'
import { polyfill } from 'es6-promise'
import fetch from 'isomorphic-unfetch'
import { actionTypes, loadDataSuccess, loadDataError } from './actions'
polyfill()
function * loadDataSaga () {
try {
const res = yield fetch('https://jsonplaceholder.typicode.com/users')
const data = yield res.json()
yield put(loadDataSuccess(data))
} catch (err) {
yield put(loadDataError(err))
}
}
export default takeLatest(actionTypes.LOAD_DATA, loadDataSaga)