generated from Dicken/dickendock
19 lines
455 B
TypeScript
19 lines
455 B
TypeScript
import { useQuery } from "@tanstack/react-query";
|
|
import type { ScanLogEntry } from "@launchpad/shared";
|
|
|
|
async function fetchLogs(): Promise<ScanLogEntry[]> {
|
|
const res = await fetch("/api/logs");
|
|
if (!res.ok) {
|
|
throw new Error(`Logs konnten nicht geladen werden (HTTP ${res.status})`);
|
|
}
|
|
return res.json();
|
|
}
|
|
|
|
export function useLogs() {
|
|
return useQuery({
|
|
queryKey: ["logs"],
|
|
queryFn: fetchLogs,
|
|
refetchInterval: 5000,
|
|
});
|
|
}
|