npm.io
0.2.4 • Published 3 years ago

api-call-simplifier

Licence
MIT
Version
0.2.4
Deps
1
Size
14 kB
Vulns
23
Weekly
0
Stars
1

api-call-simplifier

A small library that makes it easy to write a client to work with the API.

Installation

$ npm i -S api-call-simplifier

Usage

NodeJS example
const axios = require('axios');
const API = require('api-call-simplifier');


const { apiCall, resource } = API(axios.create({
    baseURL: 'https://jsonplaceholder.typicode.com',
}));

const api = {
    posts: resource('/posts'),
    comments: resource('/comments'),
    albums: resource('/albums'),
    photos: resource('/photos'),
    todos: resource('/todos'),
    users: resource('/users'),
    post: {
        comments: resource('/posts/<id>/comments')
    }
};
NuxtJS example

Edit demo-api-call-simplifier

Contributing

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request :D

Keywords