WebLink

WebLink

Currently, there is one implementation of the concept of a link, WebLink, which encapsulates the data and concepts codified in RFC5988. The standard data fields (if defined for the specific link), such as href, title, type, etc are all defined on the link.

Constructor

Create a new WebLink.

Parameters:
Name Type Description
data Object

the field values for the link

context Context

The resource context containing the link

Source:

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.

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.

Source: