mock平台

mockColReducer.js 692B

12345678910111213141516171819202122232425262728293031323334353637
  1. import axios from 'axios'
  2. import { message } from 'antd'
  3. // Actions
  4. const FETCH_MOCK_COL = 'yapi/mockCol/FETCH_MOCK_COL';
  5. // Reducer
  6. const initialState = {
  7. list: []
  8. }
  9. export default (state = initialState, action) => {
  10. switch (action.type) {
  11. case FETCH_MOCK_COL:
  12. return {
  13. ...state,
  14. list: action.payload.data
  15. }
  16. default:
  17. return state
  18. }
  19. }
  20. // Action Creators
  21. export async function fetchMockCol(interfaceId) {
  22. let result = await axios.get('/api/plugin/advmock/case/list?interface_id=' + interfaceId);
  23. if(result.errcode !==0 ){
  24. message.error(result.errmsg);
  25. }
  26. return {
  27. type: FETCH_MOCK_COL,
  28. payload: result.data
  29. }
  30. }