Re: [whatwg/fetch] Why doesn't `fetch` reject if 400 ≤ status < 600? (#18)

FWIW that can be rewritten as:

```js
return fetch(url, {
  method: 'POST',
  headers,
  body: JSON.stringify(body),
}).then((response) =>
  response.json().then((data) => {
    if (responsePromise.status >= 400) {
      throw Error(data.err);
    }
    return data;
  }),
);
```

Also, you should only reject error objects (as I've done in the example above).

-- 
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/18#issuecomment-605629519

Received on Sunday, 29 March 2020 12:37:57 UTC