import type { UseFetchOptions } from 'nuxt/app'
export function useCustomFetch<T>(
url: Parameters<typeof $fetch>[0],
options: UseFetchOptions<T> = {},
) {
return useLazyFetch(url, {
credentials: 'include',
...options,
onResponseError(context) {
if (context.response.status === 401) {
navigateTo('/login')
}
},
})
}
import type { UseFetchOptions } from 'nuxt/app'
export function useCustomFetch<T>(
url: Parameters<typeof $fetch>[0],
options: UseFetchOptions<T> = {},
) {
return useLazyFetch(url, {
credentials: 'include',
...options,
onResponseError(context) {
if (context.response.status === 401) {
navigateTo('/login')
}
},
})
}