-
-
Notifications
You must be signed in to change notification settings - Fork 443
Description
Currently it's not possible to change a request more than once in beforeRequest hooks, this behaviour is enforced here. Since this condition is hard-coded, it's impossible to change it without extending Ky base class internals.
Can this be changed? It's quite common to modify a request in a hook, and since a new instance of Request needs to be created to modify url and body, this appears to be unnatural limitation. My current case was that url path is changed in one hook, url params are changed in another hook, headers are changed in yet another hook, exactly in this order due to a hierarchy of Ky instances. Currently this requires to compose hooks on your own, or hack Ky class to fit request lifecycle, this defies the purpose of extendable Ky to some extend.
The current behaviour that silently ignores the rest of hooks is potentially more troublesome, and I'd expect this change to be an improvement, but if this can be considered breaking, it could be allowed with an option.