1/5
Easy#patchfetcherrorscorsbrowser

Don't throw HTTPError for opaque no-cors responses

sindresorhus/ky#847 · @sindresorhus · MIT · licence

a slice of a larger PR (4 files) · see it all

description
Fixes #305
1 commit · 1 file
  • 8c822e8Don't throw `HTTPError` for opaque responses from `no-cors` requests

// files changed

Msource/core/Ky.ts+2−1
@@ -128,7 +128,8 @@ export class Ky {
128128 continue;
129129 }
130130
131 if (!response.ok && (
131 // Opaque responses (`response.type === 'opaque'`) from `no-cors` requests always have `status: 0` and `ok: false`, but this is not a failure — the actual status is hidden by the browser.
132 if (!response.ok && response.type !== 'opaque' && (
132133 typeof ky.#options.throwHttpErrors === 'function'
133134 ? ky.#options.throwHttpErrors(response.status)
134135 : ky.#options.throwHttpErrors