Re: [whatwg/fetch] Add Fetch Assertions (Issue #1683)

> * Many devs (esp inexperienced) assume `fetch()` throws under conditions in which it does not

That means developers need to learn to look at the response before assuming it's ok, or they need to learn to correctly use your proposed configuration options. Those feel of similar complexity.

The current system of checking `response.ok` means you can use the response if it isn't ok. Whereas that isn't the case with this proposal.

The `acceptable` option could be split out as `response.assertAcceptable()`, which is more composable as you can check `response.ok` and `response.assertAcceptable()` separately, and react differently to each case.

However, "does the server say the response is JSON?" seems much less useful than "does the response parse as JSON?". If I'm expecting JSON, having a response that parses as JSON seems like a stronger signal that I'm getting what I expect than taking the server's word for it.

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

Message ID: <whatwg/fetch/issues/1683/1617916617@github.com>

Received on Monday, 3 July 2023 10:52:34 UTC