du.rest
Module for making queries to a REST API.Requires:
d3@v4Rest
du.rest.Rest(endpoint)
Class representing an access point to a REST API. Endpoint URL, database and table must be set at object construction and cannot be changed later on. This is to ensure that one
Rest object connects to a single table.
| arg | type | description |
|---|---|---|
| endpoint | string | Endpoint of the REST API. |
json
du.rest.Rest.json(params[, onSuccess[, onFailure[, settings]]])
Performs a query to a REST API that is expected to return a JSON file.
| arg | type | description |
|---|---|---|
| params | object | Object containing the parameters of the query. |
| onSuccess | function | Callback to perform if the query was successful. Must accept the JSON response of the query. optional |
| onFailure | function | Callback to perform if the query has failed. Must accept the error response. optional |
| settings | boolean | Optional settings before sending (e.g., for CORS). optional |
csv
du.rest.Rest.csv(params[, onSuccess[, onFailure[, settings]]])
Performs a query to a REST API that is expected to return a CSV file.
| arg | type | description |
|---|---|---|
| params | object | Object containing the parameters of the query. |
| onSuccess | function | Callback to perform if the query was successful. Must accept the CSV response of the query. optional |
| onFailure | function | Callback to perform if the query has failed. Must accept the error response. optional |
| settings | boolean | Optional settings before sending (e.g., for CORS). optional |