Bekacru / better-fetch

Advanced fetch wrapper for typescript
https://better-fetch.vercel.app/
183 stars 7 forks source link

`query` is required even when a default is provided #15

Open OwenVey opened 2 weeks ago

OwenVey commented 2 weeks ago

I have my $fetch function created like so:

export const $fetch = createFetch({
  baseURL: 'https://api.themoviedb.org/3',
  schema: createSchema({
    '/movie/:movieId': {
      params: z.object({
        movieId: z.string(),
      }),
      query: z
        .object({
          append_to_response: z.array(z.enum(['recommendations', 'similar', 'reviews'])),
        })
        .default({
          append_to_response: ['recommendations'],
        }),
    },
  }),
});

but when using that endpoint

tmdbApi('/movie/:movieId', { params: { movieId: '12345' } });

I get the following TS error Screenshot 2024-10-24 at 10 12 01 AM

The call itself still does properly add the zod default object but something with the types are off.