Network access from within browser contexts can be tricky. We've provided a convenience function to get network resources. This will be cached within our proxy and within the Player based on the caching parameter. If omitted things are cached for one hour by default.

This function eliminates the need to deal with CORS as it can be quite tricky at times.

The ttv.get(url) method returns a promise with data or an error based on the success or failure of the request.

window.onloadTelemetryTV = function (ttv) {
  ttv.get('https://www.example.com/data.json').then(data => {
    console.log('Network Get Result:', data);
  }).catch(err => {
    console.warn('Network Get Errored:', err);
  });
};

You may supply an optional caching period and headers dictionary for adding additional parameters by calling as such:

window.onloadTelemetryTV = function (ttv) {
  ttv.get(url, cachePeriod, headers).then(data => {
    // successfully fetching
  }).catch(err => {
    // codes for fetching error
  });
};

Available Arguments

Argument

Description

Type

Required

url

The URL of the target source. Must be an http or https URL.

string

true

cachePeriod

An integer in seconds for how long to cache for (minimum of 60 and a maximum of 86400 seconds).

number

false

headers

Define the HTTP GET headers.

array

false