ih-black-lion
Version:
State handler for Arus projects
21 lines (18 loc) • 584 B
JavaScript
import { takeEvery, put, call } from 'redux-saga/effects';
import { REQUEST_COURSES, RECEIVE_COURSES } from '../actionTypes';
export function* fetchCourses(action) {
try {
const response = yield call(
action.Api.getCourses,
action.requestParms,
action.subject,
action.instituion,
);
yield put({ type: RECEIVE_COURSES, response, status: 'success' });
} catch (error) {
yield put({ type: RECEIVE_COURSES, response: error, status: 'error' });
}
}
export default function* CourseSaga() {
yield takeEvery(REQUEST_COURSES, fetchCourses);
}