Closed code7070 closed 3 months ago
Hooks are async, so the request will wait for the hooks: https://github.com/sindresorhus/ky#hooksafterresponse
It sounds like you want a beforeRequest
hook, but refreshing the token in an afterResponse
hook only if a request failed, as in the example that Sindre linked to, is definitely the more idiomatic and efficient way to do it. Hope that helps!
I love Ky, especially as an alternative to migrating from axios and apicase
Can I hold or stop or perform certain requests before executing the original request using hooks?
example: if an API get-product is fired, I want to check the token first. If the token doesn't exist I want to make a token request then continue the API request.