From 8cac7935f26c12e1f8c7da77e5ba91437ecfcba9 Mon Sep 17 00:00:00 2001 From: Samuel Elliott Date: Tue, 22 Jul 2025 01:37:37 +0100 Subject: [PATCH] Coral 3.0.3 --- src/api/coral.ts | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/src/api/coral.ts b/src/api/coral.ts index cab1f96..b3775dd 100644 --- a/src/api/coral.ts +++ b/src/api/coral.ts @@ -768,19 +768,21 @@ class CoralApiRequest { ) {} async fetch(_attempt = 0): Promise> { - if (this.coral._token_expired && this.auto_renew_token && !this.coral._renewToken) { - if (!this.coral.onTokenExpired || _attempt) throw new Error('Token expired'); + if (this.auto_renew_token) { + if (this.coral._token_expired && !this.coral._renewToken) { + if (!this.coral.onTokenExpired || _attempt) throw new Error('Token expired'); - this.coral._renewToken = this.coral.onTokenExpired.call(null).then(data => { - // @ts-expect-error - if (data) this.coral.setTokenWithSavedToken(data); - }).finally(() => { - this.coral._renewToken = null; - }); - } + this.coral._renewToken = this.coral.onTokenExpired.call(null).then(data => { + // @ts-expect-error + if (data) this.coral.setTokenWithSavedToken(data); + }).finally(() => { + this.coral._renewToken = null; + }); + } - if (this.coral._renewToken && this.auto_renew_token) { - await this.coral._renewToken; + if (this.coral._renewToken) { + await this.coral._renewToken; + } } const headers = new Headers(this.headers);