// get请求 export const get = ({ url, params = {}, headers = {}, title = '加载中' }) => new Promise((resolve, reject) => { loading.open(title); axios.get(url, { params, headers, }).then((res) => { if (res.status == 200) { resolve(res.data); } else { reject(res.data); } loading.close(); }).catch((err) => { reject(err); loading.close(); }); }); // post请求 export const post = ({ url, params = {}, title = '加载中', config = {} }) => new Promise((resolve, reject) => { loading.open(title); axios.post(url, params, config).then((res) => { if (res.status == 200) { resolve(res.data); } else { reject(res.data); } loading.close(); }).catch((err) => { reject(err); loading.close(); }); });
// get请求 export const getWithOutLoading = ({ url, params = {}, headers = {} }) => new Promise((resolve, reject) => { axios.get(url, { params, headers, }).then((res) => { if (res.status == 200) { resolve(res.data); } else { reject(res.data); } }).catch((err) => { reject(err); }); }); // post请求 export const postWithOutLoading = ({ url, params = {}, config = {} }) => new Promise((resolve, reject) => { axios.post(url, params, config).then((res) => { if (res.status == 200) { resolve(res.data); } else { reject(res.data); } }).catch((err) => { reject(err); }); });