@redneckz/hal-resource

REST+HAL client for Browser and NodeJS

Stats

StarsIssuesVersionUpdatedCreatedSize
@redneckz/hal-resource
000.0.43 years ago3 years agoMinified + gzip package size for @redneckz/hal-resource in KB

Readme

hal-resource

REST+HAL client for Browser and NodeJS

NPM Version Build Status Coverage Status

Getting Started

Installation

$ npm install --save @redneckz/hal-resource
$ yarn add @redneckz/hal-resource

Basics

import { HALResource } from '@redneckz/hal-resource';

const resource = HALResource(window.fetch); // Axios can be used for NodeJS

const customersResource = resource('https://foo.com/api/v1/customers');

const sortedCustomers = customersResource.getList({ sort: { field: 'name', order: 'ASC' } });
sortedCustomers.then(console.log);

const firstCustomer = customersResource.getOne('first-customer-id');
firstCustomer.then(console.log);

const newCustomer = customersResource.create({ name: 'New Customer' });
newCustomer.then(console.log);

customersResource.delete('first-customer-id');

License

MIT

If you find any bugs or have a feature request, please open an issue on github!

The npm package download data comes from npm's download counts api and package details come from npms.io.