Static Member Summary
Static Public Members | ||
public static get |
DEFAULT_REQUEST_HEADERS: Object Default HTTP request headers applied to each outgoing request. |
|
public static get |
defaultOptions: Object Default options. |
Constructor Summary
Public Constructor | ||
public |
constructor(events: EventEmitter, options: Object) Constructor. |
Member Summary
Public Members | ||
public |
events: * |
|
public |
requestMode: String The request mode. |
|
public |
timeout: Number The request timeout. |
Method Summary
Public Methods | ||
public |
async request(url: String, request: Object, options: Object): Promise Performs an HTTP request to the Kinto server. |
Private Methods | ||
private |
_checkForBackoffHeader(status: *, headers: *) |
|
private |
_checkForDeprecationHeader(headers: *) |
|
private |
_checkForRetryAfterHeader(status: *, headers: *): * |
|
private |
async processResponse(response: *): {"status": *, "json": *, "headers": *} |
|
private |
async retry(url: *, retryAfter: *, request: *, options: *): * |
|
private |
timedFetch(url: *, options: *): * |
Static Public Members
public static get DEFAULT_REQUEST_HEADERS: Object source
Default HTTP request headers applied to each outgoing request.
Public Constructors
public constructor(events: EventEmitter, options: Object) source
Constructor.
Params:
Name | Type | Attribute | Description |
events | EventEmitter | The event handler. |
|
options | Object |
|
|
options.timeout | Number |
|
The request timeout in ms, if any (default: |
options.requestMode | String |
|
The HTTP request mode (default: |
Test:
Public Members
public events: * source
Public Methods
public async request(url: String, request: Object, options: Object): Promise source
Performs an HTTP request to the Kinto server.
Resolves with an objet containing the following HTTP response properties:
{Number} status
The HTTP status code.{Object} json
The JSON response body.{Headers} headers
The response headers object; see the ES6 fetch() spec.
Params:
Name | Type | Attribute | Description |
url | String | The URL. |
|
request | Object |
|
The request object, passed to fetch() as its options object. |
request.headers | Object |
|
The request headers object (default: {}) |
options | Object |
|
Options for making the request |
options.retry | Number |
|
Number of retries (default: 0) |
Return:
Promise |
Test:
Private Methods
private _checkForBackoffHeader(status: *, headers: *) source
Params:
Name | Type | Attribute | Description |
status | * | ||
headers | * |
private _checkForDeprecationHeader(headers: *) source
Params:
Name | Type | Attribute | Description |
headers | * |
private _checkForRetryAfterHeader(status: *, headers: *): * source
Params:
Name | Type | Attribute | Description |
status | * | ||
headers | * |
Return:
* |
private async processResponse(response: *): {"status": *, "json": *, "headers": *} source
Params:
Name | Type | Attribute | Description |
response | * |
Return:
{"status": *, "json": *, "headers": *} |
private async retry(url: *, retryAfter: *, request: *, options: *): * source
Params:
Name | Type | Attribute | Description |
url | * | ||
retryAfter | * | ||
request | * | ||
options | * |
Return:
* |
private timedFetch(url: *, options: *): * source
Params:
Name | Type | Attribute | Description |
url | * | ||
options | * |
Return:
* |