1 2 3 4 5 6 7 8 9 10 11 12 13 14
export function $api<T>( request: Parameters<typeof $fetch<T>>[0], opts?: Parameters<typeof $fetch<T>>[1], ) { const authStore = useAuthStore() return $fetch<T>(request, { ...opts, headers: { Authorization: authStore.isLoggedIn() ? `Bearer ${authStore.token}` : '', ...opts?.headers, }, }) }