0.0.15 • Published 10 years ago

isofetcher v0.0.15

Weekly downloads
3
License
MIT
Repository
github
Last release
10 years ago

isofetcher

Fetch-based REST API requests for the browser and Node.js.

Use Anywhere

This library works in the client and on the server.

Install

bower install isofetcher

Note: This requires, at a minimum, resturlify. Older browsers require es6-promises.

Or

npm install isofetcher

Examples

Constructor

var fetcher = require('isofetcher')({resources: ['foo','bar'], fqBaseUrl: 'https://www.web.com/api'});

or

var fetcher = isofetcher({resources: ['foo','bar'], fqBaseUrl: 'https://www.web.com/api'});

Basic Usage

GET
fetcher.foo.get();

Generates GET https://www.web.com/api/foo

Query Parameters
fetcher.bar.get({query: {id: 1}});

Generates GET https://www.web.com/api/bar?id=1

Custom Methods
fetcher.bar.get({customMethod: 'children');

Generates GET https://www.web.com/api/bar/children

fetcher.foo.get({customMethod: 'children', id: 1);

Generates GET https://www.web.com/api/foo/1/children

PUT
fetcher.foo.put({id: 1});

Generates PUT https://www.web.com/api/foo/1

POST
fetcher.bar.post({body: {payload: 1});

Generates POST https://www.web.com/api/bar

PATCH
fetcher.foo.get({id: 1});

Generates PATCH https://www.web.com/api/foo/1

DELETE
fetcher.foo.get({id: 1});

Generates DELETE https://www.web.com/api/foo/1

Headers

fetcher.foo.post({headers: {
  'Content-Type' : 'application/json'
});

Cookies

Cookies are not sent by default. Send the credential option to send cookies.

fetch.foo.get({credentials: 'same-origin'});
0.0.15

10 years ago

0.0.14

10 years ago

0.0.13

10 years ago

0.0.12

10 years ago

0.0.11

10 years ago

0.0.10

10 years ago

0.0.9

10 years ago

0.0.8

10 years ago

0.0.7

10 years ago

0.0.6

10 years ago

0.0.3

10 years ago

0.0.2

10 years ago

0.0.1

10 years ago