fix dual call fetch with one RTT (Promise.all)

pull/947/head
3thibaut1304 2025-07-02 14:07:01 +02:00
parent 440160fc6a
commit 2d7b8e3eef
1 changed files with 6 additions and 5 deletions

View File

@ -51,16 +51,17 @@ export default {
headers["X-SFTPGO-API-KEY"] = `${this.item.sftpgo_api_key}`; headers["X-SFTPGO-API-KEY"] = `${this.item.sftpgo_api_key}`;
} }
try { try {
const response = await this.fetch("/api/v2/version", { headers }); const [versionRes, connRes] = await Promise.all([
this.versionstring = response.version || "unknown"; this.fetch("/api/v2/version", { headers }),
this.fetch("/api/v2/connections", { headers }),
]);
const connResponse = await this.fetch("/api/v2/connections", { headers }); this.versionstring = versionRes.version || "unknown";
this.activeConnections = Array.isArray(connResponse) ? connResponse.length : null; this.activeConnections = connRes.length;
this.fetchOk = true; this.fetchOk = true;
} catch (e) { } catch (e) {
this.fetchOk = false; this.fetchOk = false;
console.log(e);
} }
}, },
}, },