dmx-cli
Version:
scaffold for create component, toolkit, page and so on
28 lines (25 loc) • 677 B
JavaScript
import { call, put } from 'redux-saga/effects';
import { takeLatest } from 'redux-saga';
import { message } from 'antd';
import fetch from 'app/util/fetch';
import { baseApi } from 'app/util/config';
import { actions, FETCH_DATA } from '../actions';
function* fetchData(action) {
try {
const res = yield call(fetch, {
url: `//${baseApi}/home`,
});
if (res) {
yield put(actions.fetchDataSuccess(res));
} else {
message.error('请求首页数据出错,请刷新页面重试', 5);
}
} catch (err) {
message.error(err.message, 5);
}
}
export default function* rootSaga() {
yield [
takeLatest(FETCH_DATA, fetchData),
];
}