{"size": 745, "ext": "js", "max_stars_repo_path": "src/components/List/sagas.js", "max_stars_repo_name": "brgermano/exercise-products-as-cards", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/components/List/sagas.js", "max_issues_repo_name": "brgermano/exercise-products-as-cards", "max_issues_repo_issues_event_min_datetime": "2020-04-03T17:18:15.000Z", "max_issues_repo_issues_event_max_datetime": "2020-04-03T17:18:15.000Z", "max_forks_repo_path": "src/components/List/sagas.js", "max_forks_repo_name": "brgermano/exercise-products-as-cards", "max_forks_repo_forks_event_min_datetime": "2019-10-01T12:29:43.000Z", "max_forks_repo_forks_event_max_datetime": "2019-10-01T12:29:43.000Z"}
{"max_stars_count": null, "max_issues_count": 1, "max_forks_count": 1, "avg_line_length": 32.3913043478, "max_line_length": 129, "alphanum_fraction": 0.7248322148}
import { takeLatest, call, put } from 'redux-saga/effects';
import { AFNPRO_EXERCISE_ADS_LIST_REQUEST, AFNPRO_EXERCISE_ADS_LIST_SUCCESS, AFNPRO_EXERCISE_ADS_LIST_FAILURE } from './actions';
import CallApi from '../Common/CallApi';

function* AdsListRequestSaga() {
  try {
    const AdsListRequestCall = yield call(CallApi, 'get', 'ads');
    const AdsListRequestData = AdsListRequestCall.data;
    const ads = AdsListRequestData.map(ad => ad.ads).flat();
    yield put({
      type: AFNPRO_EXERCISE_ADS_LIST_SUCCESS,
      ads
    });
  } catch (error) {
    yield put({
      type: AFNPRO_EXERCISE_ADS_LIST_FAILURE
    });
  }
}
export default function* ListSaga() {
  yield takeLatest(AFNPRO_EXERCISE_ADS_LIST_REQUEST, AdsListRequestSaga);
}
