Skip to content

is there a global hook to run when thrown HTTPError ? #411

Answered by sindresorhus
ma101an asked this question in Q&A
Discussion options

You must be logged in to vote

Global hooks is an anti-pattern. Ky has local hooks where you can add a hook and then use ky.extend() to create a reusable instance with such hook, which you would put in a separate file an import in various places in your app instead of the ky import. Unfortunately, Ky does not yet have a beforeError hook. For now, you could just wrap Ky in an app-specific "request" method which you use throughout your app.

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@ma101an
Comment options

@sholladay
Comment options

Answer selected by ma101an
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants