@alphatango/httpclient
v2.1.0
Published
A wrapper around axios with retry and caching logic, bearer token injection through custom resolvers and extended logging
Downloads
29
Keywords
Readme
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:
- Fork this repository
- Create a branch
- Contribute
- Pull request