refactor: modify fetcher to make it type agnostic

main
Josue 4 years ago committed by Tsu-ba-me
parent ef02ddcf81
commit 37d041e917
  1. 20
      striker-ui/lib/fetchers/periodicFetch.ts

@ -0,0 +1,20 @@
import useSWR from 'swr';
import fetcher from './fetchJSON';
const PeriodicFetch = <T>(
uuid: string,
uri: string,
refreshInterval = 2000,
): GetResponses => {
const { data, error } = useSWR<T>(`${uri}${uuid}`, fetcher, {
refreshInterval,
});
return {
data,
isLoading: !error && !data,
isError: error,
};
};
export default PeriodicFetch;
Loading…
Cancel
Save