const event = useRequestEvent();
const res = await $fetch<{ accessToken: string }>('/api/auth/refresh', {
method: 'POST',
headers: useRequestHeaders(['cookie']),
onResponse({ response }) {
const cookies = response.headers.getSetCookie();
if (cookies.length) {
cookies.forEach((cookie) => {
if (event) {
appendResponseHeader(event, 'set-cookie', cookie);
}
});
}
},
});