fetchres
Some useful response handlers for using [Fetch](https://github.com/github/fetch) API in the real world.
Last updated 4 years ago by financial-times .
Original npm · Tarball · package.json
$ cnpm install fetchres 
SYNC missed versions from official npm registry.

fetchres Build Status

Some useful response handlers for using Fetch API in the real world.

Warning: doesn't come with Fetch or Promise, so you'll need to bring your own polyfill (unless you're using this module within Service Workers, where both fetch and Promise are already defined).

Installation

npm install --save fetchres

Or

bower install --save fetchres

Usage (node)

var fetchres = require('fetchres');

fetch('https://mattandre.ws/my-json-endpoint')
	.then(fetchres.json)
	.then(function(data) {
		// `data` is an object containing the data
		// from the response, not a Response object
		console.log(data);
	})
	.catch(function(err) {
		if (err.name === fetchres.BadServerResponseError.name) {
			// just a dodgy response
			console.error(err);
		} else if (err.name === fetchres.InvalidJsonError.name) {
			// malformed json, probably
			console.error('malformed json returned');
		} else {
			// something more serious could be wrong.
			// probably want to investigate / send to
			// error aggregation service
			debugger;
		}
	});

Current Tags

  • 1.7.2                                ...           latest (4 years ago)

28 Versions

  • 1.7.2                                ...           4 years ago
  • 1.7.1                                ...           4 years ago
  • 1.7.0                                ...           4 years ago
  • 1.6.2                                ...           4 years ago
  • 1.6.1                                ...           4 years ago
  • 1.6.0                                ...           4 years ago
  • 1.5.1                                ...           5 years ago
  • 1.4.1                                ...           5 years ago
  • 1.4.0                                ...           5 years ago
  • 1.3.2                                ...           5 years ago
  • 1.3.1                                ...           5 years ago
  • 1.3.0                                ...           5 years ago
  • 1.2.0                                ...           5 years ago
  • 1.1.0                                ...           6 years ago
  • 1.0.5                                ...           6 years ago
  • 1.0.4                                ...           6 years ago
  • 1.0.3                                ...           6 years ago
  • 1.0.2                                ...           6 years ago
  • 1.0.1                                ...           6 years ago
  • 1.0.0                                ...           6 years ago
  • 0.0.8                                ...           6 years ago
  • 0.0.7                                ...           6 years ago
  • 0.0.6                                ...           6 years ago
  • 0.0.5                                ...           6 years ago
  • 0.0.4                                ...           6 years ago
  • 0.0.3                                ...           6 years ago
  • 0.0.2                                ...           6 years ago
  • 0.0.1                                ...           6 years ago

Copyright 2014 - 2016 © taobao.org |