| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | import { takeEvery, put, call } from 'redux-saga/effects';
import { REQUEST_NEWS, RECEIVE_NEWS } from '../actionTypes';
export function* fetchNews(action) {
try {
const response = yield call(action.Api.getNews, action.requestParams, action.pageletName);
yield put({ type: RECEIVE_NEWS, response, status: 'success' });
} catch (error) {
yield put({ type: RECEIVE_NEWS, response: error, status: 'error' });
}
}
export default function* NewsSaga() {
yield takeEvery(REQUEST_NEWS, fetchNews);
}
|