1616
1717import  IRESTClient ,  {  ErrorResponseHandler ,  ResponseHandler  }  from  "./IRESTClient" ; 
1818import  ClientResponse  from  "./ClientResponse" ; 
19- import  fetch ,  {  BodyInit ,  RequestCredentials ,  Response  }  from  ' node-fetch' ; 
19+ import  fetch ,  {  BodyInit ,  RequestCredentials ,  Response  }  from  " node-fetch" ; 
2020import  {  URLSearchParams  }  from  "url" ; 
2121
2222/** 
@@ -33,6 +33,7 @@ export default class DefaultRESTClient<RT, ERT> implements IRESTClient<RT, ERT>
3333  public  credentials : RequestCredentials ; 
3434  public  responseHandler : ResponseHandler < RT >  =  DefaultRESTClient . JSONResponseHandler ; 
3535  public  errorResponseHandler : ErrorResponseHandler < ERT >  =  DefaultRESTClient . ErrorJSONResponseHandler ; 
36+   public  abortSignal : AbortSignal  =  undefined ; 
3637
3738  constructor ( public  host : string )  { 
3839  } 
@@ -202,6 +203,15 @@ export default class DefaultRESTClient<RT, ERT> implements IRESTClient<RT, ERT>
202203    return  this ; 
203204  } 
204205
206+   /** 
207+    * Sets the AbortSignal for the request. 
208+    * @param  signal The AbortSignal to use to abort the request. 
209+    */ 
210+   withAbortSignal ( signal : AbortSignal ) : DefaultRESTClient < RT ,  ERT >  { 
211+     this . abortSignal  =  signal ; 
212+     return  this ; 
213+   } 
214+ 
205215  /** 
206216   * Run the request and return a promise. This promise will resolve if the request is successful 
207217   * and reject otherwise. 
@@ -219,8 +229,7 @@ export default class DefaultRESTClient<RT, ERT> implements IRESTClient<RT, ERT>
219229            body : this . body  as  BodyInit , 
220230            // @ts -ignore (Credentials are not supported on NodeJS) 
221231            credentials : this . credentials , 
222-             // 60-second timeout expressed in ms 
223-             timeout : 60000 , 
232+             abort : this . abortSignal , 
224233          } , 
225234      ) ; 
226235
0 commit comments