error.js 596 Bytes
Newer Older
1 2
import { routerRedux } from 'dva/router';
import { query } from '../services/error';
3 4 5 6 7 8 9 10 11 12

export default {
  namespace: 'error',

  state: {
    error: '',
    isloading: false,
  },

  effects: {
13 14 15 16
    *query({ payload }, { call, put }) {
      yield call(query, payload.code);
      // redirect on client when network broken
      yield put(routerRedux.push(`/exception/${payload.code}`));
17 18
      yield put({
        type: 'trigger',
19
        payload: payload.code,
20 21 22 23 24 25 26 27 28 29 30 31
      });
    },
  },

  reducers: {
    trigger(state, action) {
      return {
        error: action.payload,
      };
    },
  },
};