mirror of
https://github.com/hubHarmony/servii-frontend.git
synced 2024-11-17 21:40:30 +00:00
[+] Fixed optimization issue
This commit is contained in:
parent
1fe1d04292
commit
f9aec3805c
@ -3,6 +3,8 @@ import {Bounce, toast} from "react-toastify";
|
|||||||
|
|
||||||
const apiUrl: string = 'https://www.servii.fr/api';
|
const apiUrl: string = 'https://www.servii.fr/api';
|
||||||
//const apiUrl: string = 'http://localhost:3000';
|
//const apiUrl: string = 'http://localhost:3000';
|
||||||
|
let token_fetched: boolean = false;
|
||||||
|
let token: string;
|
||||||
|
|
||||||
interface ApiResponse {
|
interface ApiResponse {
|
||||||
return_code: number;
|
return_code: number;
|
||||||
@ -124,7 +126,14 @@ class serviiApi {
|
|||||||
|
|
||||||
private static async token(): Promise<string> {
|
private static async token(): Promise<string> {
|
||||||
try {
|
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) {
|
} catch (error) {
|
||||||
throw new Error("No token retrieved.");
|
throw new Error("No token retrieved.");
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user