ky icon indicating copy to clipboard operation
ky copied to clipboard

beforeRequest hook called after beforeRetry

Open hamdiwanis opened this issue 1 year ago • 3 comments

Please verify if this is the correct flow or not I was not expecting "beforeRequest "to be called again after "beforeRetry", my use case is that I refresh the token and set the Authorization header in "beforeRetry "but it gets overridden by "beforeRequest".

thanks in advance.

hamdiwanis avatar Apr 16 '23 13:04 hamdiwanis

I think this is expected behavior. It's called for every single request with no exception. A retry is a request. We should clearly point that out in the docs, however.

Maybe the request could somehow indicate that it's a request caused by a retry.

sindresorhus avatar Apr 20 '23 11:04 sindresorhus

Got it thanks for your response

hamdiwanis avatar Apr 20 '23 12:04 hamdiwanis

No need to close. There are unresolved tasks here.

sindresorhus avatar Apr 20 '23 12:04 sindresorhus