Files
BayIQ-UI/src/features/cameras/hooks/useGetVideoFeed.ts
2025-11-27 10:43:56 +00:00

24 lines
701 B
TypeScript

import { useQuery } from "@tanstack/react-query";
import { CAMBASE } from "../../../utils/config";
const getfeed = async (cameraFeedID: "A" | "B" | "C" | null) => {
const response = await fetch(`${CAMBASE}TargetDetectionColour${cameraFeedID}-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 = (cameraFeedID: "A" | "B" | "C" | null) => {
const videoQuery = useQuery({
queryKey: ["getfeed", cameraFeedID],
queryFn: () => getfeed(cameraFeedID),
refetchInterval: 500,
});
return { videoQuery };
};