umi.js model模板

import { queryTopicList } from '@/services/topic';

export default {
  namespace: 'topic',
  state: {
    topicList: [],
  },

  effects: {
    *queryTopicList({ payload }, { call, put }) {
      const response = yield call(queryTopicList, payload);
      if (response.code === 0) {
        yield put({
          type: 'saveTopicList',
          payload: {
            data: response,
          },
        });
      } else {
        // eslint-disable-next-line no-console
        console.log('request failed');
      }
    },
  },

  reducers: {
    saveTopicList(state, action) {
      return {
        ...state,
      };
    },
  },
};

你可能感兴趣的:(umi.js model模板)