doFetch.js 780 Bytes
Newer Older
wuhao's avatar
wuhao committed
1
import request from './request';
wuhao's avatar
wuhao committed
2
import defaultSetting from '../../config/defaultSettings';
wuhao's avatar
wuhao committed
3 4 5 6 7

export async function doFetch({ url, params }) {
  if (!url) {
    return;
  }
wuhao's avatar
wuhao committed
8 9 10 11 12 13 14 15 16 17 18
  if (url.indexOf('token') != -1) {
    return request(url, {
      method: 'post',
      data: params,
    });
  } else {
    return request(defaultSetting.proxypath + url, {
      method: 'post',
      data: params,
    });
  }
wuhao's avatar
wuhao committed
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
}

export async function postFetch({ url, params }) {
  return request(url, {
    method: 'post',
    data: params,
  });
}

export async function getFetch({ url, params }) {
  return request(url, {
    method: 'get',
    params,
  });
}

export async function formFetch({ url, params }) {
  return request(url, {
    method: 'post',
    data: params,
    type: 'form',
  });
}