You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
19 lines
370 B
19 lines
370 B
import useSWR from 'swr'; |
|
import fetcher from './fetchJSON'; |
|
|
|
const PeriodicFetch = <T>( |
|
url: string, |
|
uuid: string, |
|
refreshInterval = 2000, |
|
): GetResponses => { |
|
const { data, error } = useSWR<T>(`${url}${uuid}`, fetcher, { |
|
refreshInterval, |
|
}); |
|
return { |
|
data, |
|
isLoading: !error && !data, |
|
isError: error, |
|
}; |
|
}; |
|
|
|
export default PeriodicFetch;
|
|
|