[+] Fixed optimization issue

Merge pull request #48 from hubHarmony/plugin-management-system
This commit is contained in:
charleslemaux 2024-09-21 12:05:51 +02:00 committed by GitHub
commit 784695084e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -3,6 +3,8 @@ import {Bounce, toast} from "react-toastify";
const apiUrl: string = 'https://www.servii.fr/api';
//const apiUrl: string = 'http://localhost:3000';
let token_fetched: boolean = false;
let token: string;
interface ApiResponse {
return_code: number;
@ -124,7 +126,14 @@ class serviiApi {
private static async token(): Promise<string> {
try {
return await auth.currentUser.getIdToken(true);
if (!token_fetched) {
token = await auth.currentUser.getIdToken(true);
token_fetched = true;
return token;
}
else {
return token;
}
} catch (error) {
throw new Error("No token retrieved.");
}