3-helper-function
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 (err) {
yield put({ type: "FETCH_FAILED", err });
}
}import { takeEvery } from "redux-saga/effects";
function* watchFetchData() {
yield takeEvery("FETCH_REQUESTED", fetchData);
}Summary
Last updated
Was this helpful?