Install the SDK

How to install the SDK into your app.

Installation

Our SDK can be installed from either NPM or Bower, depending on your intended usage.

If you are integrating into a classical JavaScript project and you just want to include a script that exposes some global objects in your page, then use Bower.

If you are using a project that utilises ES6 modules like angular2, ionic2 or similar, then use NPM.

Bower

1. Install package from Bower

bower install comapi-sdk-js-foundation

2. Include the script

<script src="bower_components/comapi-sdk-js-foundation/dist/comapi-foundation.js"></script>

There is also a minified version comapi-foundation.min.js available.

For all subsequent classical snippets, I will assume that this script has been included

3. Access SDK methods

console.log("Comapi version: " + COMAPI.Foundation.version);

NPM

1. Install the SDK

npm install @comapi/sdk-js-foundation --save

2. Import into your code and access SDK methods


import { Foundation } from "@comapi/sdk-js-foundation"

class MyClass{
    public displayVersion(){
        console.log(`Comapi version: ${Foundation.version}`);
    }
}


📘

Use of ES6 Promises

ES6 Promises are extensively used within this SDK. Depending on what browsers you are targeting, you may need to include a poly-fill for this. Several of these are available online.