1.2.3 • Published 8 years ago
fetcho v1.2.3
fetcho: a useful fetch tiny wrapper
Usage: like fetch, it prefills headers opts for convenience, and body is automatically JSON.stringified
import fetcho from 'fetcho';
// or const fetcho = require('fetcho');
fetcho('https://httpbin.org/get?test=foo')
.then(console.log)
fetcho('https://httpbin.org/post', {method: 'POST', body: {test: 'foo'}})
.then(console.log)How does it compare to axios?
- it uses
window.fetchin browser (polyfill it if needed, with polyfill.io for example),node-fetch+fetch-cookie - Supports the Promise API: yes of course, like fetch
- Intercept request and response: no, just wrap it yourself
- Transform request and response data: no, same answer
- Cancel requests: use
AbortController(polyfill.io might have it soon, or use the suggested polyfills https://github.com/Financial-Times/polyfill-service/issues/1722) Automatic transforms for JSON data - Client side support for protecting against XSRF: no