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 🙏🏼 |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
|
Shouldn't you use the |
Beta Was this translation helpful? Give feedback.
-
|
We have an example of this in the docs: https://github.com/sindresorhus/ky#hooksafterresponse |
Beta Was this translation helpful? Give feedback.
We have an example of this in the docs: https://github.com/sindresorhus/ky#hooksafterresponse