23 lines
543 B
TypeScript
23 lines
543 B
TypeScript
|
|
import { useQuery } from "@tanstack/react-query";
|
||
|
|
|
||
|
|
const getfeed = async () => {
|
||
|
|
const response = await fetch(`http://100.115.148.59/TargetDetectionColour-preview`, {
|
||
|
|
signal: AbortSignal.timeout(300000),
|
||
|
|
cache: "no-store",
|
||
|
|
});
|
||
|
|
if (!response.ok) {
|
||
|
|
throw new Error(`Cannot reach endpoint (${response.status})`);
|
||
|
|
}
|
||
|
|
return response.blob();
|
||
|
|
};
|
||
|
|
|
||
|
|
export const useGetVideoFeed = () => {
|
||
|
|
const videoQuery = useQuery({
|
||
|
|
queryKey: ["getfeed"],
|
||
|
|
queryFn: getfeed,
|
||
|
|
refetchInterval: 500,
|
||
|
|
});
|
||
|
|
|
||
|
|
return { videoQuery };
|
||
|
|
};
|