jclib-ui 1.0.51 → 1.0.53

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -7677,7 +7677,7 @@ const initialRequestInfo = {
7677
7677
  report: false,
7678
7678
  onBefore: null
7679
7679
  };
7680
- function useApi(initialConfig) {
7680
+ function useApi(initialConfig = {}) {
7681
7681
  const history = useHistory();
7682
7682
  const controller = new AbortController();
7683
7683
  const { globalApiConfig } = useLibContext();
@@ -7697,7 +7697,7 @@ function useApi(initialConfig) {
7697
7697
  username: globalApiConfig.auth.username,
7698
7698
  password: globalApiConfig.auth.password
7699
7699
  };
7700
- initialConfig.headers = {};
7700
+ initialConfig.headers = { ...initialConfig.headers, ...localConfig == null ? void 0 : localConfig.headers };
7701
7701
  if (globalApiConfig.getToken) {
7702
7702
  let token = globalApiConfig.getToken();
7703
7703
  if (token) {
@@ -7711,25 +7711,30 @@ function useApi(initialConfig) {
7711
7711
  initialConfig.cache = Boolean(
7712
7712
  globalApiConfig.isProductionMode && (!initialConfig.method || initialConfig.method == "get")
7713
7713
  );
7714
- if (initialConfig == null ? void 0 : initialConfig.cache)
7714
+ if (initialConfig.cache) {
7715
7715
  await cache.init(initialConfig);
7716
+ }
7716
7717
  let finalConfig = {
7717
7718
  baseURL: globalApiConfig.baseURL,
7718
7719
  timeout: globalApiConfig.timeout,
7719
7720
  auth,
7720
7721
  validateStatus: (status) => status >= 200 && status < 400,
7721
7722
  ...initialConfig,
7722
- ...localConfig
7723
+ ...localConfig,
7724
+ headers: initialConfig.headers
7723
7725
  };
7724
- if (finalConfig.report)
7726
+ if (finalConfig.report) {
7725
7727
  finalConfig = { ...finalConfig, responseType: "blob", timeout: 0 };
7728
+ }
7726
7729
  setRequestInfo({ ...initialRequestInfo, loading: true });
7727
- if (finalConfig.onBefore)
7730
+ if (finalConfig.onBefore) {
7728
7731
  finalConfig.onBefore(finalConfig);
7732
+ }
7729
7733
  try {
7730
7734
  const res = await axios({ ...finalConfig, signal: controller.signal });
7731
- if (globalApiConfig.afterRequest)
7735
+ if (globalApiConfig.afterRequest) {
7732
7736
  globalApiConfig.afterRequest(res);
7737
+ }
7733
7738
  response = {
7734
7739
  ...initialRequestInfo,
7735
7740
  data: res.data,