Skip to content

mmaruniak/AT-HttpClient

 
 

Repository files navigation

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

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • TypeScript 100.0%