Files
probo/apps/console/src/hooks/useFetchQuery.ts
Émile Ré dd23449cc0 Fix apps/console lint issues
Signed-off-by: Émile Ré <emile@getprobo.com>
2026-01-22 12:51:43 +04:00

16 lines
381 B
TypeScript

import { useQuery, type UseQueryOptions } from "@tanstack/react-query";
/**
* Wrapper around useQuery to fetch data from an API endpoint
*/
export function useFetchQuery<T>(
url: string,
options?: Omit<UseQueryOptions<T>, "queryKey" | "queryFn">,
) {
return useQuery<T>({
...options,
queryKey: [url],
queryFn: () => fetch(url).then(res => res.json()),
});
}