import service from "./config.mjs";
import "../../../_virtual/FileSaver.min.mjs";
import { paramHandler, successRollback, errRollback } from "./util.mjs";
function get(url, showLoading = true) {
  return new Promise((resolve, reject) => {
    paramHandler(null, showLoading);
    service.get(url).then((res) => {
      successRollback(resolve, res);
    }).catch((err) => {
      errRollback(reject, err);
    });
  });
}
function post(url, params, showLoading = true) {
  return new Promise((resolve, reject) => {
    params = paramHandler(params, showLoading);
    service.post(url, params).then((res) => {
      successRollback(resolve, res);
    }).catch((err) => {
      errRollback(reject, err);
    });
  });
}
function postForm(url, params, showLoading = true, isUpload = false) {
  return new Promise((resolve, reject) => {
    params = paramHandler(params, showLoading, isUpload);
    service.postForm(url, params, { headers: { isUpload } }).then((res) => {
      successRollback(resolve, res);
    }).catch((err) => {
      errRollback(reject, err);
    });
  });
}
export {
  get,
  post,
  postForm
};
