Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
4 tasks done
hungify opened this issue May 4, 2024 · 2 comments
Open
4 tasks done
Labels
enhancement New feature or request

Comments

@hungify
Copy link

hungify commented May 4, 2024

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

@hungify hungify added the enhancement New feature or request label May 4, 2024
@hungify hungify changed the title [UseFetch] Forward all options to fetch rather than few options [UseFetch and CreateFetch] Forward all options to fetch rather than few options May 6, 2024
@paulwer
Copy link

paulwer commented May 26, 2024

Have you had any success combining both?

@hungify
Copy link
Author

hungify commented May 26, 2024

Do you mean to combine openapi-fetch library with useFetch?
Not yet, I have successfully combined the openapi-fetch library with ofetch.
But I want to take advantage of the benefits of useFetch, but it's running into the problem mentioned above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants