Slide 12
Slide 12 text
import { call, put } from 'redux-saga/effects';
export function* fetchData(action) {
try {
const data = yield call(Api.fetchUser, action.payload.url);
yield put({type: "FETCH_SUCCEEDED", data});
} catch (error) {
yield put({type: "FETCH_FAILED", error});
}
}
function* watchFetchData() {
yield takeEvery('FETCH_REQUESTED', fetchData);
}
https://redux-saga.github.io/redux-saga/docs/basics/UsingSagaHelpers.html