@kohost/api-client 3.0.0-beta.22 → 3.0.0-beta.24

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.
package/dist/esm/defs.js CHANGED
@@ -2515,6 +2515,7 @@ var require_Client = __commonJS({
2515
2515
  throw new Error("options.property is required");
2516
2516
  this.options = options;
2517
2517
  this.isBrowser = typeof window !== "undefined";
2518
+ this.isRefreshingToken = false;
2518
2519
  const config = {
2519
2520
  baseURL: options.url,
2520
2521
  responseType: "json",
@@ -2576,19 +2577,22 @@ var require_Client = __commonJS({
2576
2577
  return Promise.reject(error);
2577
2578
  }
2578
2579
  if (expectedError && newTokensNeeded) {
2579
- return this.RefreshToken().then(() => {
2580
- return this._http(originalReq);
2581
- });
2580
+ while (!this.isRefreshingToken) {
2581
+ this.isRefreshingToken = true;
2582
+ return this.RefreshToken().then(() => {
2583
+ this.isRefreshingToken = false;
2584
+ return this._http(originalReq);
2585
+ }).catch((err) => {
2586
+ this.isRefreshingToken = false;
2587
+ return Promise.reject(err);
2588
+ });
2589
+ }
2582
2590
  }
2583
2591
  } catch (error2) {
2584
2592
  console.log(error2);
2585
2593
  }
2586
2594
  return Promise.reject(error);
2587
2595
  }
2588
- /*
2589
- @param {String} token - The token to set
2590
- @returns undefined
2591
- */
2592
2596
  _onLoginRequired() {
2593
2597
  this.emit("LoginRequired");
2594
2598
  }