RestConnection
RestConnection
This sends queries to a given endpoint over HTTP using RESTful conventions. If additional query methods are called, these are encoded in the (http) query string.
The endpoint must be set before this connection is used.
Constructor Summary
Public Constructor | ||
public |
constructor(endpoint: string) Create a new RestConnection |
Method Summary
Public Methods | ||
public |
buildOptions(method: string, data: Object, options: Object): Object Get an options hash for the fetch |
|
public |
Get endpoint URL with the entity ID or query data appended. |
|
public |
Run an INSERT query. |
|
public |
Run a DELETE query. |
|
public |
Run a SELECT query. |
|
public |
Send an HTTP request and return a Promise. |
|
public |
Take a fetch response and extract the JSON. |
|
public |
Run an UPDATE query. |
|
public |
Get a URL to the endpoint. |
Public Constructors
Public Methods
public buildOptions(method: string, data: Object, options: Object): Object source
Get an options hash for the fetch init
parameter.
public buildUrl(suffix: string | number | array): string source
Get endpoint URL with the entity ID or query data appended.
public create(data: Object): Promise source
Run an INSERT query.
Params:
Name | Type | Attribute | Description |
data | Object |
Test:
public sendRequest(urlSuffix: string | number | Array, method: string, body: Object): Promise source
Send an HTTP request and return a Promise.
public unwrap(response: Response): Object source
Take a fetch response and extract the JSON.
Params:
Name | Type | Attribute | Description |
response | Response |