JavaScript

Overview

This library contains all the API calls needed to communicate with the HAT.

  • Authentication

  • Fetch Applications, Data Plugs and Data Debits

  • Read and write data to endpoints

  • File API

Setting Up Environment

Supported Environments

The @dataswift/hat-js library works in all modern browsers. Some older browsers do not support all the features required. If you want to support these browsers you need to load polyfill for Promise.

Installation

Install the @dataswift/hat-js package via npm or pull from our CDN.

NPM installation

npm install @dataswift/hat-js

CDN Link

<script src="https://cdn.dataswift.io/libs/hatjs/hat-0.3.0.min.js"></script>

Usage

Importing

ES6

import { HatClient } from "@dataswift/hat-js";

ES5 Modules

var HatClient = require("@dataswift/hat-js").HatClient;

Initialisation

Configuration type:

interface HatClientConfig {
    apiVersion?: string; // Api Version for the HAT. eg. v2.6
    hatDomain?: string; // The HAT domain of the user. eg. testing.hubat.net
    token?: string; // The Application token.
    secure?: boolean; // If you want to run the HAT locally, you have to modify this field to 'false'.
    onTokenChange?: Function;
}

Example:

const config = {
    token: "<access-token>",
    apiVersion: 'v2.6',
    secure: true,
    onTokenChange: (newToken) => storeNewToken(newToken)
};

const hat = new HatClient(config);

Last updated