mirror of
https://github.com/hydralauncher/hydra.git
synced 2025-02-03 08:43:48 +03:00
fix: await and conditional
This commit is contained in:
parent
ba08e0b112
commit
7bbaae91c9
@ -31,7 +31,7 @@ export class HydraApi {
|
|||||||
|
|
||||||
private static async revalidateAccessTokenIfExpired() {
|
private static async revalidateAccessTokenIfExpired() {
|
||||||
const now = new Date();
|
const now = new Date();
|
||||||
if (this.userAuth.expirationTimestamp > now.getTime()) {
|
if (this.userAuth.expirationTimestamp < now.getTime()) {
|
||||||
const response = await this.instance.post(`/auth/refresh`, {
|
const response = await this.instance.post(`/auth/refresh`, {
|
||||||
refreshToken: this.userAuth.refreshToken,
|
refreshToken: this.userAuth.refreshToken,
|
||||||
});
|
});
|
||||||
@ -66,22 +66,22 @@ export class HydraApi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static async get(url: string) {
|
static async get(url: string) {
|
||||||
this.revalidateAccessTokenIfExpired();
|
await this.revalidateAccessTokenIfExpired();
|
||||||
return this.instance.get(url, this.getAxiosConfig());
|
return this.instance.get(url, this.getAxiosConfig());
|
||||||
}
|
}
|
||||||
|
|
||||||
static async post(url: string, data?: any) {
|
static async post(url: string, data?: any) {
|
||||||
this.revalidateAccessTokenIfExpired();
|
await this.revalidateAccessTokenIfExpired();
|
||||||
return this.instance.post(url, data, this.getAxiosConfig());
|
return this.instance.post(url, data, this.getAxiosConfig());
|
||||||
}
|
}
|
||||||
|
|
||||||
static async put(url, data?: any) {
|
static async put(url, data?: any) {
|
||||||
this.revalidateAccessTokenIfExpired();
|
await this.revalidateAccessTokenIfExpired();
|
||||||
return this.instance.put(url, data, this.getAxiosConfig());
|
return this.instance.put(url, data, this.getAxiosConfig());
|
||||||
}
|
}
|
||||||
|
|
||||||
static async patch(url, data?: any) {
|
static async patch(url, data?: any) {
|
||||||
this.revalidateAccessTokenIfExpired();
|
await this.revalidateAccessTokenIfExpired();
|
||||||
return this.instance.patch(url, data, this.getAxiosConfig());
|
return this.instance.patch(url, data, this.getAxiosConfig());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user