Skip to content

Commit 9447d04

Browse files
committed
[misc]: workaround for react query generics
1 parent acb2a19 commit 9447d04

File tree

1 file changed

+15
-16
lines changed

1 file changed

+15
-16
lines changed

frontend/src/api/api.ts

+15-16
Original file line numberDiff line numberDiff line change
@@ -48,23 +48,22 @@ function useApiHook<T>({
4848
}) {
4949
const [session] = useSession();
5050

51-
return useQuery<T>(
52-
queryKey,
53-
async () => {
54-
const res = await fetch(url, {
55-
headers: {
56-
'X-AuthToken': session?.token || '',
57-
},
58-
});
59-
60-
if (res.status >= 400 && res.status < 600) {
61-
throw new RequestError(res.status);
62-
}
51+
const fetchData = async (): Promise<T> => {
52+
const res = await fetch(url, {
53+
headers: {
54+
'X-AuthToken': session?.token || '',
55+
},
56+
});
57+
58+
if (res.status >= 400 && res.status < 600) {
59+
throw new RequestError(res.status);
60+
}
61+
62+
return res.json();
63+
};
6364

64-
return res.json();
65-
},
66-
useQueryOptions
67-
);
65+
// TODO: figure out generics for fetchData
66+
return useQuery<T>(queryKey, fetchData as any, useQueryOptions);
6867
}
6968

7069
const useUpdateQueryDataFromEvents = ({

0 commit comments

Comments
 (0)