after response for get refresh token #381
|
I may be a bit confused about how to explain it, I hope those who read this understand. in my case I'm trying to fetch a refresh token on the const authAfterResponseHooks: AfterResponseHook = async (req, _, res) => {
if (res.status === 401) {
const token = await base
.post('integration/customer/token')
.json<string>();
req.headers.set('Authorization', 'Bearer ' + token);
if (typeof token !== 'string') {
return Promise.reject(new Response('Errors token not get', { status: 400 }));
}
await Storage.setItem('token', token);
return base(req);
}
};note: maybe someone can shed some light on this matter. thanks 🙏🏼 |
Answered by
sindresorhus
Oct 11, 2025
Replies: 2 comments
|
Shouldn't you use the |
0 replies
|
We have an example of this in the docs: https://github.com/sindresorhus/ky#hooksafterresponse |
0 replies
Answer selected by
sindresorhus
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
We have an example of this in the docs: https://github.com/sindresorhus/ky#hooksafterresponse