vueuse / vueuse

Collection of essential Vue Composition Utilities for Vue 2 and 3

Home Page:https://vueuse.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[UseFetch and CreateFetch] Forward all options to fetch rather than few options

hungify opened this issue · comments

I am attempting to utilize the openapi-fetch library with useFetch to exploit their combined features.
I am having trouble using openapi-fetch with useFetch as it doesn't forward all param options to custom fetch.

  if (args.length > 1 && isFetchOptions(args[1]))
    options = { ...options, ...args[1] }
  // `options` contains my custom properties but it doesn't forward to fetch
  const { fetch = window?.fetch, initialData, timeout } = options
  return fetch(context.url, {
      ...defaultFetchOptions,
      ...context.options,
      headers: {
        ...headersToObject(defaultFetchOptions.headers),
        ...headersToObject(context.options?.headers),
      },
    })

Suggested solution

I suggest that useFetch should forward all fetch options like useFetch in Nuxt.

Alternative

No response

Additional context

No response

Validations