Class: JsonClientSupport

JsonClientSupport

An abstract class with customizable JSON client support.


<abstract> new JsonClientSupport( [authBuilder])

Constructor.

Parameters:
Name Type Argument Description
authBuilder AuthorizationV2Builder <optional>

the auth builder to authenticate requests with; if not provided then only public data can be queried

Members


<protected> authBuilder :AuthorizationV2Builder

An authorization builder to use to make authenticated HTTP requests.

Type:
  • AuthorizationV2Builder

Methods


client( [value])

Get or set a JSON HTTP client function to use.

The function must be compatible with d3.json and defaults to that. This provides a way to integrate a different HTTP client if needed, for example a mock implementation in tests.

Parameters:
Name Type Argument Description
value function <optional>

the JSON client function, compatible with d3.json

Returns:

when used as a getter, the JSON client function, otherwise this object

Type
function | DatumSourceFinder

fetch()

Asynchronously load the data.

This method calls JsonClientSupport#load to perform the actual work.

Returns:

the result promise

Type
Promise.<*>

<abstract> load(callback)

Asynchronously load the data using a callback.

Extending classes must override this method to provide a useful implementation.

Parameters:
Name Type Description
callback JsonClientSupport~dataCallback

the callback function to invoke

Returns:
Type
void

Type Definitions


dataCallback( [error], data)

The data callback function.

Parameters:
Name Type Argument Description
error Error <optional>

an error if a failure occurred

data *

the result data