-
-
Notifications
You must be signed in to change notification settings - Fork 377
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Allow returning Response
from a beforeRequest
hook
#172
Allow returning Response
from a beforeRequest
hook
#172
Conversation
@sindresorhus can you restart travis please ? the failed build seems to be some random puppeteer timeout. |
@hugomrdias |
cool then this is ready for review |
index.js
Outdated
@@ -383,7 +383,10 @@ class Ky { | |||
async _fetch() { | |||
for (const hook of this._hooks.beforeRequest) { | |||
// eslint-disable-next-line no-await-in-loop | |||
await hook(this._input, this._options); | |||
const hookOutput = await hook(this._input, this._options); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hookOutput
-> result
Co-Authored-By: Szymon Marczak <36894700+szmarczak@users.noreply.github.com>
Co-Authored-By: Szymon Marczak <36894700+szmarczak@users.noreply.github.com>
Response
from a beforeRequest
hook
The docs part should have been added to index.d.ts. Otherwise, looks good. |
I think the types should also be updated 🤔 can't get TS to accept returning a |
This PR adds support to return a Response from the beforeRequest hook and completely skip the HTTP request.
closes #157
/cc @lidel