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

top level query in createFetch() doesn't merge with schema #16

Open
OwenVey opened this issue Oct 25, 2024 · 1 comment
Open

top level query in createFetch() doesn't merge with schema #16

OwenVey opened this issue Oct 25, 2024 · 1 comment

Comments

@OwenVey
Copy link

OwenVey commented Oct 25, 2024

In my case, the OMDb API required an apikey query param passed in every request so I set up my createFetch like so:

export const omdbApi = createFetch({
  baseURL: 'http://www.omdbapi.com',
  query: {
    apikey: 'xxxxxxxx',
  },
  schema: createSchema(
    {
      '/': {
        query: z.object({
          i: z.string(),
        }),
      },
    },
  ),
});

However, when calling the API like so

omdbApi('/', { query: { i: 'tt22022452'} })

only the i query param gets sent.

@sinanusluer
Copy link

I think you can use the onRequest hook.

Docs: https://better-fetch.vercel.app/docs/hooks#on-request 🤟

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

No branches or pull requests

2 participants