Request
A Request should only ever be created by an instance of Http
Constructor Summary
Public Constructor | ||
public |
constructor(config: Object) |
Method Summary
Public Methods | ||
public |
body(value: Object | FormData | Blob | File | String, serializer: Serializer): Object | FormData | Blob | File | String | Request |
|
public |
contentType(value: String): String | Request Convenience method for getting/setting the Content-Type header. |
|
public |
|
|
public |
|
|
public |
interceptors(value: Interceptor[]): Interceptor[] | Request |
|
public |
|
|
public |
|
|
public |
responseType(value: String): String | Request XHRProvider only - sets the responseType field of the XMLHttpRequest |
|
public |
serializer(value: Serializer): Serializer | Request |
|
public |
|
|
public |
|
|
public |
|
|
public |
withCredentials(value: Boolean): Boolean | Request |
|
public |
xsrfCookieName(value: String): String | Request |
|
public |
xsrfHeaderName(value: String): String | Request |
Public Constructors
Public Methods
public body(value: Object | FormData | Blob | File | String, serializer: Serializer): Object | FormData | Blob | File | String | Request source
Params:
Name | Type | Attribute | Description |
value | Object | FormData | Blob | File | String |
|
The body for this request |
serializer | Serializer |
|
The serializer for the body |
public contentType(value: String): String | Request source
Convenience method for getting/setting the Content-Type header.
Params:
Name | Type | Attribute | Description |
value | String |
|
The value of the Content-Type header |
public execute(): Object source
Return:
Object | Executes the request and returns an object containing the response, uploadProgress, and downloadProgress streams. |
Example:
var streams = request.execute();
streams.flatMap(response => response.body()).forEach((body) => console.log(body));
streams.flatmap(response => response.uploadProgress()).forEach((event) => console.log(event));
streams.flatMap(response => response.downloadProgress()).forEach((event) => console.log(event));
public headers(name: String | Object, value: *): Object | String | Request source
Return:
Object | String | Request | If no parameters are specified - returns a copy of the entire headers hash. |
Example:
request.headers() // returns { "foo": "bar" }
If only name is specified, and name is a string - returns the value for the key in the headers hash.
request.headers("foo") // returns "bar"
If only name is specified, and name is an object - replaces the entire headers hash
and returns the current Request.
request.headers({ "foo": "bar", "baz": 1 })
If name and value are specified - sets the value of name in the headers hash
and returns the current Request.
request.headers("foo", "bar")
public interceptors(value: Interceptor[]): Interceptor[] | Request source
Params:
Name | Type | Attribute | Description |
value | Interceptor[] |
|
The set of interceptors to be run against this Request and/or Response |
Return:
Interceptor[] | Request | If value is specified, overrides the current set of interceptors for this Request and/or Response and returns the current Request. If value is ommitted, returns the current set of interceptors. |
public method(value: String): String | Request source
Params:
Name | Type | Attribute | Description |
value | String |
|
The HTTP method for this request |
public password(value: String): String | Request source
Params:
Name | Type | Attribute | Description |
value | String |
|
Basic auth password |
public responseType(value: String): String | Request source
XHRProvider only - sets the responseType field of the XMLHttpRequest
Params:
Name | Type | Attribute | Description |
value | String |
|
The expected responseType |
public serializer(value: Serializer): Serializer | Request source
Params:
Name | Type | Attribute | Description |
value | Serializer |
|
The serializer for the body |
Return:
Serializer | Request | If value is specified, sets the Serializer for this request and returns the current Request. If value is ommitted, returns the current Serializer |
public timeout(value: Number): Number | Request source
Params:
Name | Type | Attribute | Description |
value | Number |
|
The request timeout in milliseconds |
public user(value: String): String | Request source
Params:
Name | Type | Attribute | Description |
value | String |
|
Basic auth user |
public withCredentials(value: Boolean): Boolean | Request 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 | Request source
Params:
Name | Type | Attribute | Description |
value | String |
|
The name of the XSRF cookie |