js-api-client
v1.0.7
Published
Javascript api client wrapper for Axios
Downloads
29
Maintainers
Readme
Javascript Api Client
Javascript api client wrapper around Axios.
Installation
With yarn
yarn add js-api-client
With npm
npm install js-api-client --save
Usage
import ApiClient from 'js-api-client';
const client = new ApiClient({
baseURL: 'https://www.some-api-base-url.com',
});
// get
const getResponse = client.get('/users/1')
.then(successHandler)
.catch(errorHandler);
// post
const userData = {
firstName: 'Luis',
lastName: 'Colon',
};
const postResponse = client.post('/users', userData)
.then(successHandler)
.catch(errorHandler);
// etc