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}`;
}
try {
const response = await this.fetch("/api/v2/version", { headers });
this.versionstring = response.version || "unknown";
const [versionRes, connRes] = await Promise.all([
this.fetch("/api/v2/version", { headers }),
this.fetch("/api/v2/connections", { headers }),
]);
const connResponse = await this.fetch("/api/v2/connections", { headers });
this.activeConnections = Array.isArray(connResponse) ? connResponse.length : null;
this.versionstring = versionRes.version || "unknown";
this.activeConnections = connRes.length;
this.fetchOk = true;
} catch (e) {
this.fetchOk = false;
console.log(e);
}
},
},