1.0.2 • Published 2 years ago

@emilgroup/typescript-axios-sdk v1.0.2

Weekly downloads
-
License
Unlicense
Repository
-
Last release
2 years ago

@emilgroup/typescript-axios-sdk@1.0.2

This TypeScript/JavaScript client utilizes axios. The generated Node module can be used in the following environments:

Environment

  • Node.js
  • Webpack
  • Browserify

Language level

  • ES5 - you must have a Promises/A+ library installed
  • ES6

Module system

  • CommonJS
  • ES6 module system

It can be used in both TypeScript and JavaScript. In TypeScript, the definition should be automatically resolved via package.json. (Reference)

Consuming

navigate to the folder of your consuming project and run one of the following commands.

npm install @emilgroup/typescript-axios-sdk@1.0.2 --save

And then you can import EmilApi.

import { EmilApi } from '@emilgroup/typescript-axios-sdk';

const emilApi = new EmilApi();

To use authentication protected endpoints, you have to first authorize. To do so, use the authorize function in EmilApi:

async function listAccounts(): Promise<Void> {
    try {
        const emilApi = new EmilApi();

        await emilApi.authorize('username', 'password');

        const { data: { items } } = await emilApi.accounts.listAccounts();

        console.log(items);
    } catch(error) {
      // process error
  }
}