From 7bbaae91c9d454ae26e5f77777abd938b558bc50 Mon Sep 17 00:00:00 2001 From: Zamitto <167933696+zamitto@users.noreply.github.com> Date: Thu, 13 Jun 2024 22:52:29 -0300 Subject: [PATCH] fix: await and conditional --- src/main/services/hydra-api.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/services/hydra-api.ts b/src/main/services/hydra-api.ts index ac08b91f..776021ea 100644 --- a/src/main/services/hydra-api.ts +++ b/src/main/services/hydra-api.ts @@ -31,7 +31,7 @@ export class HydraApi { private static async revalidateAccessTokenIfExpired() { const now = new Date(); - if (this.userAuth.expirationTimestamp > now.getTime()) { + if (this.userAuth.expirationTimestamp < now.getTime()) { const response = await this.instance.post(`/auth/refresh`, { refreshToken: this.userAuth.refreshToken, }); @@ -66,22 +66,22 @@ export class HydraApi { } static async get(url: string) { - this.revalidateAccessTokenIfExpired(); + await this.revalidateAccessTokenIfExpired(); return this.instance.get(url, this.getAxiosConfig()); } static async post(url: string, data?: any) { - this.revalidateAccessTokenIfExpired(); + await this.revalidateAccessTokenIfExpired(); return this.instance.post(url, data, this.getAxiosConfig()); } static async put(url, data?: any) { - this.revalidateAccessTokenIfExpired(); + await this.revalidateAccessTokenIfExpired(); return this.instance.put(url, data, this.getAxiosConfig()); } static async patch(url, data?: any) { - this.revalidateAccessTokenIfExpired(); + await this.revalidateAccessTokenIfExpired(); return this.instance.patch(url, data, this.getAxiosConfig()); } }