Constructor
new HttpClient(baseURL)
Instantiates new HTTP client with the supplied base URL and default request timeouts.
Parameters:
Name | Type | Description |
---|---|---|
baseURL |
string | base URL that will be prepend to all requests GET |
- Source:
Methods
getBaseURL() → {string}
Returns the base URL which this http client uses to send requests.
- Source:
Returns:
the base URL for each request
- Type
- string
request(requestBuilder) → {Promise.<any>}
Performs HTTP request using the supplied request builder.
Parameters:
Name | Type | Description |
---|---|---|
requestBuilder |
HttpRequestBuilder |
- Source:
Returns:
a promise resolving to the request's response
- Type
- Promise.<any>
setDefaultHeaders(headers) → {HttpClient}
Sets the provided header map as default for all requests.
Any additional headers provided in the request configuration will be merged with this default map.
Parameters:
Name | Type | Description |
---|---|---|
headers |
Map.<string, string> | map with default headers |
- Source:
Returns:
the current client for method chaining
- Type
- HttpClient
setDefaultReadTimeout(readTimeout) → {HttpClient}
Sets the default request read timeout. It will be used in case requests don't explicitly specify it in their request configurations.
Parameters:
Name | Type | Description |
---|---|---|
readTimeout |
number | the default read timeout |
- Source:
Returns:
the current client for method chaining
- Type
- HttpClient
setDefaultWriteTimeout(writeTimeout) → {HttpClient}
Sets the default request write timeout. It will be used in case requests don't explicitly specify it in their request configurations.
Parameters:
Name | Type | Description |
---|---|---|
writeTimeout |
number | the default write timeout |
- Source:
Returns:
the current client for method chaining
- Type
- HttpClient