1.0.7 • Published 7 years ago

js-api-client v1.0.7

Weekly downloads
1
License
MIT
Repository
github
Last release
7 years ago

Javascript Api Client

Build Status Coverage Status GitHub license NPM downloads GitHub issues

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