Custom Fetch Types not align
I have following custom composable function:
import type { UseFetchOptions } from '#app'
export function useCraftFetch<T>(
url: string | Request | Ref<string | Request> | (() => string | Request),
options: UseFetchOptions<T> = {}
) {
const { authToken } = useRuntimeConfig().public.craftcms
const headers = {
'Authorization': authToken,
}
const customOptions: UseFetchOptions<T> = {
...options,
headers: {
...headers,
...(options.headers || {})
}
}
return useFetch<T>(url, customOptions)
}
And I get a ts error in the useFetch part where customOptions is set. Why is that?
import type { UseFetchOptions } from '#app'
export function useCraftFetch<T>(
url: string | Request | Ref<string | Request> | (() => string | Request),
options: UseFetchOptions<T> = {}
) {
const { authToken } = useRuntimeConfig().public.craftcms
const headers = {
'Authorization': authToken,
}
const customOptions: UseFetchOptions<T> = {
...options,
headers: {
...headers,
...(options.headers || {})
}
}
return useFetch<T>(url, customOptions)
}
And I get a ts error in the useFetch part where customOptions is set. Why is that?
