import {
  message,
} from 'antd';

const fetch = (params) => {
  const {
    Api,
    name,
    fetchParams = {},
    logic,
  } = params;

  Api[name](fetchParams).then(cb => {
    const {
      api_status,
    } = cb;

    if (api_status) {
      logic(cb);
    } else {
      message.error();
    }
  }).catch(error => {
    message.error();
  });
}

export {
  fetch
}