@apipass/apipass-api-js-sdk
TypeScript icon, indicating that this package has built-in type declarations

1.2.1 • Public • Published

@apipass/apipass-api-js-sdk

apipass-api-js-sdk is a js sdk for connect to APIPASS api's

Installation

run in your project

npm install @apipass/apipass-api-js-sdk

Angular Usage

  • add script in angular.json
"scripts": [
   "node_modules/@apipass/apipass-api-js-sdk/src/apipass-api-js-sdk.js"
]
  • import in your app.component and initialize with your jwt-token
import {Component, OnInit} from '@angular/core';
import {ApipassSDK} from "@apipass/apipass-api-js-sdk/src/apipass-api-js-sdk";

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})
export class AppComponent implements OnInit {

  constructor() {}
  
  async ngOnInit(): Promise<void> {
    await ApipassSDK.init('<YOUR-TOKEN>');

    // SDK IS READY FOR USE HERE
    const company = await ApipassSDK.findCompany();
  }
  
}

Another Application Usages:

  • import script "node_modules/@apipass/apipass-api-js-sdk/dist/src/apipass-api-js-sdk.js" in your application

  • you can use with promise callbacks:

ApipassSDK.init('<YOUR-TOKEN>', '<CLIENT-ID>', '<CLIENT-NAME>').then(() => {
  console.log('Hello SDK! SDK is Ready inside this promise callback');
      
  ApipassSDK.findCompany().then(company => {
    // get your company inside this promise callback
    console.log('myCompany', company);
  })
      
});
  • or you can use async / await functions
async startApp(): Promise<void> {
  await ApipassSDK.init('<YOUR-TOKEN>');
  console.log('Hello SDK! SDK is Ready after this line!');

  // get your company
  const company = await ApipassSDK.findCompany();
}

Readme

Keywords

Package Sidebar

Install

npm i @apipass/apipass-api-js-sdk

Weekly Downloads

17

Version

1.2.1

License

ISC

Unpacked Size

222 kB

Total Files

44

Last publish

Collaborators

  • apipass