File tree 1 file changed +15
-16
lines changed
1 file changed +15
-16
lines changed Original file line number Diff line number Diff line change @@ -48,23 +48,22 @@ function useApiHook<T>({
48
48
} ) {
49
49
const [ session ] = useSession ( ) ;
50
50
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
+ } ;
63
64
64
- return res . json ( ) ;
65
- } ,
66
- useQueryOptions
67
- ) ;
65
+ // TODO: figure out generics for fetchData
66
+ return useQuery < T > ( queryKey , fetchData as any , useQueryOptions ) ;
68
67
}
69
68
70
69
const useUpdateQueryDataFromEvents = ( {
You can’t perform that action at this time.
0 commit comments