1.2.0 • Published 6 years ago

ez-fetch v1.2.0

Weekly downloads
11
License
MIT
Repository
github
Last release
6 years ago

ez-fetch

A fetch wrapper to simplify network requests.

  • Includes es6-promise, isomorphic-fetch for use in older browsers and for use in a node.js environment
  • Inspects content-type header to parse response correctly
  • Throws an error (catch) if the response is not OK
  • Stringifies JSON and sets content-type header

Examples

const ezFetch = require('ez-fetch');

// GET
ezFetch
  .get('https://example.com')
  .then(body => {
    console.log(body);
  }).catch(error => {
    console.error(error);
  });

// POST, PATCH, PUT, DELETE
// url, body, fetchOptions
ezFetch
  .post('https://example.com/create', {
    title: 'Hello World'
  }, {
    headers: {
      Authorization: 'Bearer 12345'
    }
  }).then(result => {
    console.log(result);
  }).catch(error => {
    console.error(error);
  });
1.2.0

6 years ago

1.1.2

6 years ago

1.1.1

6 years ago

1.1.0

6 years ago

1.0.1

6 years ago

1.0.0

7 years ago