Skip to content

Escher request library for Escher authenticated API clients

License

Notifications You must be signed in to change notification settings

dkorpos/escher-suiteapi-js

 
 

Repository files navigation

@emartech/escher-request

Usage

Javascript

const { EscherRequest, EscherRequestOption } = require('@emartech/escher-request');

const options = new EscherRequestOption('example.host.com', {
  credentialScope: 'eu/service/ems_request'
});
const request = EscherRequest.create('escher.key', 'escher.secret', options);

const heroId = 1;
const hero = await request.get(`/heroes/${heroId}`);
console.log(hero);

const heroes = await request.post('/heroes', {
  name: 'Captain America',
  sex: 'male'
});
console.log(heroes);

Typescript

import { EscherRequest, EscherRequestOption } from '@emartech/escher-request';

const options = new EscherRequestOption('example.host.com', {
  credentialScope: 'eu/service/ems_request'
});
const request = EscherRequest.create('escher.key', 'escher.secret', options);

const heroId = 1;
const hero = await request.get<{ name: string; }>(`/heroes/${heroId}`);
console.log(hero);

const heroes = await request.post<{ name: string; }[]>('/heroes', {
  name: 'Captain America',
  sex: 'male'
});
console.log(heroes);

Retry

You can specify an optional retry config in the constructor of the EscherRequestOption's second parameter:

const options = new EscherRequestOption('example.host.com', {
  credentialScope: 'eu/service/ems_request',
  retryConfig: {
      retries: 5
  }
});

The type of the retryConfig property is IAxiosRetryConfig, you can find the detailed list of available parameters here: https://github.com/softonic/axios-retry#options

About

Escher request library for Escher authenticated API clients

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 100.0%