Attaches a hook to end of hooks.beforeRequest (incl. after one-off hooks specified in the call to fetch(), e.g. setExpectedStatus)
Workaround to fix
afterResponse breaking >20MB file downloads.
Ky clones the response when using afterResponse. Cloning causes requests to stop requesting data after 2x highWaterMark (we use 10 MB) unless all clones consume data at the same time. This workaround uses beforeRequest hook to skip ky's fetch call + afterResponse handling, and reimplements both.
WARNING: Use caution if modifying response.json or response.body in hooks. In vanilla ky every hook receives its own clone of the response; with this workaround, the same response object is passed to all hooks, so changes propagate (somewhat mitigated by readonly fields on Response). In addition, response.body can only be read once.
TODO: remove if fixed by https://github.com/sindresorhus/ky/pull/356
Generated using TypeDoc