Root

Root

new Root(url, http, extensions, defaultOptionsopt)

Entrypoint to an API.

Parameters:
Name Type Attributes Description
url string

The URL of the root of the API

http

The ES6 promise based HTTP abstraction (e.g. AngularJS $http, or axios

extensions Array

The extensions to use for processing responses

defaultOptions Object <optional>

Default options used when following links. See Context#withDefaults and WebLink#follow

Source:

Extends

Methods

follow(optionsopt)

Dereference the link, returning an asynchronously populated Resource.

Parameters:
Name Type Attributes Description
options Object <optional>

The options for the request.

Properties
Name Type Attributes Description
protocol Object <optional>

Options to pass to the underlying protocol,

preferContextMediaType Boolean <optional>

Whether to prefer the media type that originated this WebLink in the Accept header of the request, e.g. Accept: application/vnd.collection+json, application/vnd.siren+json;q=0.5

data Object <optional>

When following a link that is a URI Template, this object will used as variables when resolving the template into the final URI.

Inherited From:
Source:
Tutorials:

resolvedUrl(data)

The resolvedUrl function of a HyRes.WebLink can be used to see what the final resolved URL will be for the link once processing:

  • URI Template parameters passed in the data argument.
  • Converting any relative URLs to absolute ones given the context of the web link, i.e. the URL of the response that contained the link.
Parameters:
Name Type Description
data Object

The values to optionally insert into any URI template used for the href value.

Inherited From:
Source: