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

I prefer to do like this

```return new Promise((resolve, reject) => {
        fetch(url, {
            method: POST,
            headers,
            body: JSON.stringify(body),
        })
            .then((res) => {
                const response = res;
                const responsePromise = res.json();
                responsePromise
                    .then((data) => {
                        if (response.status >= 400) {
                            reject(data);
                        } else {
                            resolve(data);
                        }
                    })
                    .catch((error) => {
                        reject(error);
                    });
            });
    });
```

-- 
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-605626293

Received on Sunday, 29 March 2020 12:08:51 UTC