Http
An HTTP client.
Constructor Summary
Public Constructor | ||
public |
constructor(options: Object) |
Method Summary
Public Methods | ||
public |
addInterceptor(interceptor: Interceptor): Http |
|
public |
|
|
public |
|
|
public |
|
|
public |
|
|
public |
interceptors(values: Interceptor[]): Interceptor[] | Http |
|
public |
|
|
public |
|
|
public |
|
|
public |
|
|
public |
|
|
public |
removeInterceptor(interceptor: Interceptor): Http |
|
public |
|
|
public |
|
|
public |
|
|
public |
|
|
public |
withCredentials(value: Boolean): Boolean | Http |
|
public |
xsrfCookieName(value: String): String | Http |
|
public |
xsrfHeaderName(value: String): String | Http |
Public Constructors
Public Methods
public addInterceptor(interceptor: Interceptor): Http source
Params:
Name | Type | Attribute | Description |
interceptor | Interceptor | Add the interceptor to the end of the chain of interceptors. |
public delete(url: String, opts: Object): Request source
Example:
new Http({ baseUrl: 'http://mydomain.com', timeout: 5000 }).delete('/some/stuff', {
retries: 2,
timeout: 10000
})
public get(url: String, opts: Object): Request source
Example:
new Http({ baseUrl: 'http://mydomain.com', timeout: 5000 }).get('/some/stuff', {
retries: 2
timeout: 10000
})
public head(url: string, opts: Object): Request source
Example:
new Http({ baseUrl: 'http://mydomain.com', timeout: 5000 }).head('/some/stuff', {
retries: 2,
timeout: 10000
})
public interceptors(values: Interceptor[]): Interceptor[] | Http source
Params:
Name | Type | Attribute | Description |
values | Interceptor[] |
|
An array of interceptors. |
Return:
Interceptor[] | Http | If values is specified, replaces the default interceptors for all requests from this client, and returns the client instance. If values is ommitted, returns the current array of interceptors. |
public options(url: String, opts: Object): Request source
Example:
new Http({ baseUrl: 'http://mydomain.com', timeout: 5000 }).head('/some/stuff', {
retries: 2,
timeout: 10000
})
public password(value: String): String | Http source
Params:
Name | Type | Attribute | Description |
value | String |
|
Basic auth password |
public patch(url: String, opts: Object): Request source
Example:
new Http({ baseUrl: 'http://mydomain.com', timeout: 5000 }).patch('/some/stuff', {
body: { foo: "bar", baz: 1 },
timeout: 10000
})
public post(url: String, opts: Object): Request source
Example:
new Http({ baseUrl: 'http://mydomain.com', timeout: 5000 }).post('/some/stuff', {
body: { foo: "bar", baz: 1 },
timeout: 10000
})
public put(url: String, opts: Object): Request source
Example:
new Http({ baseUrl: 'http://mydomain.com', timeout: 5000 }).put('/some/stuff', {
body: { foo: "bar", baz: 1 },
timeout: 10000
})
public removeInterceptor(interceptor: Interceptor): Http source
Params:
Name | Type | Attribute | Description |
interceptor | Interceptor | Remove the interceptor from the chain of interceptors. |
public request(url: String, options: Object): Request source
Example:
new Http({ baseUrl: 'http://mydomain.com', timeout: 5000 }).request('/some/stuff', {
method: 'POST',
body: { foo: "bar", baz: 1 },
timeout: 10000
})
public timeout(value: Number): Number | Http source
Params:
Name | Type | Attribute | Description |
value | Number |
|
The request timeout in milliseconds |
public trace(url: String, opts: Object): Request source
Example:
new Http({ baseUrl: 'http://mydomain.com', timeout: 5000 }).trace('/some/stuff', {
retries: 2,
timeout: 10000
})
public user(value: String): String | Http source
Params:
Name | Type | Attribute | Description |
value | String |
|
Basic auth username |
public withCredentials(value: Boolean): Boolean | Http source
Params:
Name | Type | Attribute | Description |
value | Boolean |
|
Flag indicating whether cross-site AccessControl requests should be made using cookies, authorization headers, or TLS client certificates. More detail: https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/withCredentials |
public xsrfCookieName(value: String): String | Http source
Params:
Name | Type | Attribute | Description |
value | String |
|
The name of the XSRF cookie |