mirror of https://github.com/bastienwirtz/homer
fix dual call fetch with one RTT (Promise.all)
parent
440160fc6a
commit
2d7b8e3eef
|
@ -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);
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue