Re: [whatwg/fetch] why not add an option of json (#430)

@Galen-Yip I don't think this should be part of the API, but you can do it yourself:

```js
function fetchType(request, type, opts={}) {
  if (!['json', 'arrayBuffer', 'blob', 'formData', 'text'].includes(type)) {
    return Promise.reject(TypeError('Invalid response type'));
  }
  return fetch(request, opts).then(r => r[type]());
}

// usage:
fetchType('/', 'json').then(data => …);
```

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/fetch/issues/430#issuecomment-265501189

Received on Wednesday, 7 December 2016 16:47:50 UTC