13 .then(response => response.json())
26 res.text() // response body (=> Promise)
27 res.json() // parse via JSON (=> Promise)
29 res.statusText //=> 'OK'
30 res.redirected //=> false
32 res.url //=> 'http://site.com/data.json'
34 // ('cors' 'default' 'error'
35 // 'opaque' 'opaqueredirect')
37 res.headers.get('Content-Type')
46 body: new FormData(form), // post body
47 body: JSON.stringify(...),
50 'Accept': 'application/json'
53 credentials: 'same-origin', // send cookies
54 credentials: 'include', // send cookies, even in CORS
67 function checkStatus (res) {
68 if (res.status >= 200 && res.status < 300) {
71 let err = new Error(res.statusText)
78 Non-2xx responses are still successful requests. Use another function to turn them to errors.
80 ### Using with node.js
83 const fetch = require('isomorphic-fetch')
86 See: [isomorphic-fetch](https://npmjs.com/package/isomorphic-fetch) _(npmjs.com)_
91 - <https://fetch.spec.whatwg.org/>
92 - <https://www.npmjs.com/package/whatwg-fetch>