sipp11
7 years ago
5 changed files with 48 additions and 5 deletions
@ -0,0 +1,19 @@
|
||||
import { call, put, takeEvery, takeLatest } from 'redux-saga/effects' |
||||
import { apiClient } from './utils/ApiClient' |
||||
import * as types from './constants/ActionTypes' |
||||
|
||||
function* fetchStop(action) { |
||||
try { |
||||
const url = `/stop/?${action.payload.query || ''}` |
||||
const stops = yield call(apiClient, url) |
||||
yield put({type: types.STOP_SUCCESS, payload: stops.data}) |
||||
} catch (e) { |
||||
yield put({type: types.STOP_FAILURE, message: e.message}) |
||||
} |
||||
} |
||||
|
||||
function* mySaga() { |
||||
yield takeLatest(types.STOP_REQUEST, fetchStop) |
||||
} |
||||
|
||||
export default mySaga |
Loading…
Reference in new issue