36 lines
1.0 KiB
Vue
36 lines
1.0 KiB
Vue
import request from "./request";
|
|
export default async function api(params) {
|
|
return await Common(params);
|
|
}
|
|
async function Common(arg) {
|
|
//取环境变量拿host
|
|
const { url, data = {}, params = {}, method = 'get' } = arg;
|
|
const options = {
|
|
method
|
|
};
|
|
isEmpty(data) || (options.data = data);
|
|
isEmpty(params) || (options.params = params);
|
|
try {
|
|
const res = await request(url, options);
|
|
// console.log("这一步", res)
|
|
document.getElementById("wholeCover").style.display = "none";
|
|
return res;
|
|
}
|
|
catch (e) {
|
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
//@ts-ignore
|
|
// console.log(e);
|
|
document.getElementById("wholeCover").style.display = "none";
|
|
return Promise.reject(e);
|
|
// window.Raven && window.Raven.captureException(e);
|
|
}
|
|
}
|
|
/**
|
|
* 是否是空对象
|
|
* @param param
|
|
*/
|
|
function isEmpty(param) {
|
|
// console.log(param);
|
|
return !Object.keys(param).length;
|
|
}
|
|
//# sourceMappingURL=fetch.js.map |