@alphatango/httpclient
TypeScript icon, indicating that this package has built-in type declarations

2.1.0 • Public • Published

ATSquad HTTP Client

A wrapper around axios with retry and caching logic, bearer token injection through custom resolvers, and extended logging.

Using this library

Install the library.

yarn add @alphatango/httpclient
const HttpClient = require('@alphatango/httpclient');
const Logger = require('@alphatango/logger');

let logger = new Logger();
let httpClient = new HttpClient({
  logFunction: msg => logger.log(msg),
  tokenResolver: () => "exampleAccessToken"
});

let headers = {};
let data = { exampleProperty: 'exampleValue' };

let getResponse = await httpClient.get('VALID_URL', { headers });
let postResponse = await httpClient.post('VALID_URL', data, { headers });
let putResponse = await httpClient.put('VALID_URL', data, { headers });

If you wish to override the axios defaults and/or add your own interceptors, provide an axios instance in the configuration object.

const axios = require('axios');
let axiosClient = axios.create({ timeout: 3000 });
new HttpClient({ client: axiosClient });

Contribution

We value your input as part of direct feedback to us, by filing issues, or preferably by directly contributing improvements:

  1. Fork this repository
  2. Create a branch
  3. Contribute
  4. Pull request

Readme

Keywords

none

Package Sidebar

Install

npm i @alphatango/httpclient

Weekly Downloads

1

Version

2.1.0

License

MIT

Unpacked Size

15 kB

Total Files

9

Last publish

Collaborators

  • dboerlage
  • wparad
  • thoean
  • alphatango-deploy
  • akincel