Ky: Modify the request URL in the `beforeRequest` hook

Created on 22 Aug 2019  路  3Comments  路  Source: sindresorhus/ky

I want to edit request url in the beforeRequest hook.
Thx.

enhancement help wanted

All 3 comments

Have you tried? Or are you saying it's not working?

I think he meant the latter.

https://github.com/sindresorhus/ky/blob/83dff35a23a022e2c039ef2e1df966f619f9c206/index.js#L383-L387

https://github.com/sindresorhus/ky/blob/83dff35a23a022e2c039ef2e1df966f619f9c206/index.js#L226

Strings are immutable. We could pass this as the third argument, but that wouldn't be elegant.

Perhaps we should allow beforeRequest hooks to return a Request instance, which we would pass to fetch(). That would allow them to use any URL they want, as well as other options. Should be pretty easy to implement.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sindresorhus picture sindresorhus  路  7Comments

popuguytheparrot picture popuguytheparrot  路  6Comments

ShivamJoker picture ShivamJoker  路  5Comments

jacob-fueled picture jacob-fueled  路  3Comments

sindresorhus picture sindresorhus  路  4Comments