Should `status = 0` be considered `ok` for `mode: no-cors`-requests?
According to the WHATWG Spec., status should be set to 0 for a so called opaque response stemming from a mode: "no-cors"-request. Interestingly enough, it's not considered an "OK" response in regards to response.ok (only includes 2xx).
Regardless, should 0 be treated as OK for no-cors-requests? I.e. should ky not throw an HTTPError in such cases? If it indeed should, is there/can we provide some sort of mechanism to treat a status code as an OK response?
Would be a good idea!
Doing this makes sense to me. But I think it could be confusing for Ky to succeed with a response where response.ok is false.
To me, the real solution is to fix https://github.com/whatwg/fetch so that response.ok correctly reflects the meaning of the response status. Could you file an issue over there?
Sure, will do. Thanks!
Oy, that thread makes me sad for the web. Well, thanks for trying.
I guess it's on library authors to wallpaper over this issue. Domenic's solution of !res.ok && res.type !== 'opaque' looks reasonable to me. I'm in favor of implementing it, so long as it's well documented (i.e. consider how this impacts the explanation of HTTPError and the throwHttpErrors option and everything else).