lari-api-client

0.0.3 • Public • Published

Lari Api Client

Install

npm install lari-api-client

Create routes config file:

// routes.js
export default {
    options: {
        prefix: '/api/'
    },
    GET: {
        search: 'search'
    },
    POST: {
        test: 'test/route'
    },
    UPDATE: {},
    DELETE: {},
    RESOURCE: {
        products: 'products'
    }
}

Initialize api

import Api from 'lari-api-client';
import axios from 'axios';
import routes from './routes';

export default new Api(
    axios, routes
);

Example use:

api.get('test', parameters)
api.post('test', payload, parameters)
api.delete('test', parameters)
api.update('test', payload, parameters)
api.resource('products').index(parameters)
api.resource('products').store(payload, parameters)
api.resource('products').show(id, parameters)
api.resource('products').update(id, payload, parameters)
api.resource('products').delete(id, parameters)

Readme

Keywords

Package Sidebar

Install

npm i lari-api-client

Weekly Downloads

0

Version

0.0.3

License

MIT

Last publish

Collaborators

  • ablydev