mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
1 parent
9aa5b5d875
commit
a0e992a3ea
1 file changed
+5
-3
@@ -56,6 +56,10 @@ export interface JsonApiConfig {
|
|||||||
debug?: boolean;
|
debug?: boolean;
|
||||||
getRequestOptions?: () => Promise<RequestInit>;
|
getRequestOptions?: () => Promise<RequestInit>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const httpAgent = new HttpAgent({ keepAlive: true });
|
||||||
|
const httpsAgent = new HttpsAgent({ keepAlive: true });
|
||||||
|
|
||||||
export class JsonApi<D = JsonApiData, P extends JsonApiParams = JsonApiParams> {
|
export class JsonApi<D = JsonApiData, P extends JsonApiParams = JsonApiParams> {
|
||||||
static reqInitDefault: RequestInit = {
|
static reqInitDefault: RequestInit = {
|
||||||
headers: {
|
headers: {
|
||||||
@@ -98,9 +102,7 @@ export class JsonApi<D = JsonApiData, P extends JsonApiParams = JsonApiParams> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!reqInit.agent) {
|
if (!reqInit.agent) {
|
||||||
const agentOpts = { keepAlive: true };
|
reqInit.agent = reqUrl.startsWith("https:") ? httpsAgent : httpAgent;
|
||||||
|
|
||||||
reqInit.agent = reqUrl.startsWith("https:") ? new HttpsAgent(agentOpts) : new HttpAgent(agentOpts);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (query) {
|
if (query) {
|
||||||
|
|||||||
Reference in new issue
Block a user