du.rest

Module for making queries to a REST API.

Requires: d3@v4

Rest

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.
argtypedescription
endpointstringEndpoint 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.
argtypedescription
paramsobjectObject containing the parameters of the query.
onSuccessfunctionCallback to perform if the query was successful. Must accept the JSON response of the query. optional
onFailurefunctionCallback to perform if the query has failed. Must accept the error response. optional
settingsbooleanOptional 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.
argtypedescription
paramsobjectObject containing the parameters of the query.
onSuccessfunctionCallback to perform if the query was successful. Must accept the CSV response of the query. optional
onFailurefunctionCallback to perform if the query has failed. Must accept the error response. optional
settingsbooleanOptional settings before sending (e.g., for CORS). optional