1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00
Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>
This commit is contained in:
Jari Kolehmainen 2021-11-17 18:18:26 +02:00
parent 9aa5b5d875
commit a0e992a3ea

View File

@ -56,6 +56,10 @@ export interface JsonApiConfig {
debug?: boolean;
getRequestOptions?: () => Promise<RequestInit>;
}
const httpAgent = new HttpAgent({ keepAlive: true });
const httpsAgent = new HttpsAgent({ keepAlive: true });
export class JsonApi<D = JsonApiData, P extends JsonApiParams = JsonApiParams> {
static reqInitDefault: RequestInit = {
headers: {
@ -98,9 +102,7 @@ export class JsonApi<D = JsonApiData, P extends JsonApiParams = JsonApiParams> {
}
if (!reqInit.agent) {
const agentOpts = { keepAlive: true };
reqInit.agent = reqUrl.startsWith("https:") ? new HttpsAgent(agentOpts) : new HttpAgent(agentOpts);
reqInit.agent = reqUrl.startsWith("https:") ? httpsAgent : httpAgent;
}
if (query) {