Skip to content

Commit 93cc3f4

Browse files
committed
feat: add timeout method
1 parent 1de022b commit 93cc3f4

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

code/src/http/httpClient.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -475,6 +475,19 @@ export default class HttpClient {
475475
}
476476
}
477477

478+
/**
479+
* Specify the timeout (in milliseconds) for the pending request.
480+
*
481+
* @param {number} milliseconds
482+
*
483+
* @returns {this}
484+
*/
485+
public timeout(milliseconds: number): this {
486+
this.withOption('signal', AbortSignal.timeout(milliseconds));
487+
488+
return this;
489+
}
490+
478491
/**
479492
* Specify the basic authentication username and password for the request.
480493
*

code/src/http/types/options.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@ export type Options = {
44
body?: FormData | string | URLSearchParams;
55
credentials?: RequestCredentials;
66
headers?: Headers;
7+
signal?: AbortSignal;
78
[key: string]: RequestOptions;
89
};

0 commit comments

Comments
 (0)