ih-black-lion
Version:
State handler for Arus projects
16 lines (13 loc) • 520 B
JavaScript
import { takeEvery, put, call } from 'redux-saga/effects';
import { REQUEST_PROFILE, RECEIVE_PROFILE } from '../actionTypes';
export function* fetchProfile(action) {
try {
const response = yield call(action.Api.getProfile, action.requestParams);
yield put({ type: RECEIVE_PROFILE, response, status: 'success' });
} catch (error) {
yield put({ type: RECEIVE_PROFILE, response: error, status: 'error' });
}
}
export default function* ProfileSaga() {
yield takeEvery(REQUEST_PROFILE, fetchProfile);
}