|
|
@ -2,14 +2,13 @@ import useSWR from 'swr'; |
|
|
|
import fetcher from './fetchJSON'; |
|
|
|
import fetcher from './fetchJSON'; |
|
|
|
|
|
|
|
|
|
|
|
const PeriodicFetch = <T>( |
|
|
|
const PeriodicFetch = <T>( |
|
|
|
|
|
|
|
url: string, |
|
|
|
uuid: string, |
|
|
|
uuid: string, |
|
|
|
uri: string, |
|
|
|
|
|
|
|
refreshInterval = 2000, |
|
|
|
refreshInterval = 2000, |
|
|
|
): GetResponses => { |
|
|
|
): GetResponses => { |
|
|
|
const { data, error } = useSWR<T>(`${uri}${uuid}`, fetcher, { |
|
|
|
const { data, error } = useSWR<T>(`${url}${uuid}`, fetcher, { |
|
|
|
refreshInterval, |
|
|
|
refreshInterval, |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
return { |
|
|
|
return { |
|
|
|
data, |
|
|
|
data, |
|
|
|
isLoading: !error && !data, |
|
|
|
isLoading: !error && !data, |
|
|
|