supabase-js
supabase-js copied to clipboard
Ability to add arguments to supabase custom fetch documented
Improve documentation
It is possible to set a custom fetch that supabase client will use. But how are arguments passed to this custom fetch with the query builder api?
Link
https://supabase.com/docs/reference/javascript/select How to pass arguments to a custom fetch?
Describe the problem
It is unclear if it is possible or how to pass arguments to a custom fetch. Clippy did have some ideas; but these did not work when tried.
Describe the improvement
Show an example of the query building api using custom fetch and additional arguments being past to it.
Additional context
For my specific use case - is it possible to use the nextjs 13 fetch and pass arguments to set per query caching instead of being limited to using segment level caching as shown in the documentation currently export const revalidate = 60.
It is unclear if it is possible or how to accomplish passing arguments to the specified custom fetch
Its fully possible, see https://github.com/supabase/supabase-js/issues/725#issuecomment-1578811299
@sannajammeh I tried this a few days ago, and typescript threw all sorts of errors?
@sannajammeh I tried this a few days ago, and typescript threw all sorts of errors?
Most likely you have conflicting environment types from the types that supabase expects from fetch. This is common in almost all frameworks where fetch is polyfilled with node-fetch or similar.
I would simply place a // @ts-expect-error comment above the line as it's most likely a type conflict between global type of RequestInit and Supabase's internal type of RequestInit. Without seeing your error I won't know for sure though.
@sannajammeh What if I want to add a tag to a particular data request that I can revalidate later with revalidateTag ?