A generic API client.
Run yarn add @ffflorian/api-client
or npm install @ffflorian/api-client
.
A complete documentation is available at https://ffflorian.github.io/api-clients/packages/api-client/.
import {APIClient} from '@ffflorian/api-client';
const apiClient = new APIClient('https://example.com/api/v1');
apiClient.requestService
.get('/endpoint', {
headers: {
Authorization: 'my-api-key',
},
})
.then(data => {
// ...
});
import {APIClient} from '@ffflorian/api-client';
const apiClient = new APIClient({
apiUrl: 'https://example.com/api/v1',
requestInjector: config => {
const hawkHeader = hawk.client.header(config.url, config.method, {credentials});
return {
...config,
headers: {
Authorization: hawkHeader.header,
},
};
},
});
apiClient.requestService.get('/endpoint').then(data => {
// ...
});
yarn
yarn dist
Generated using TypeDoc