generated from Dicken/dickendock
Commit 3: Suche im Frontend mit echten Backend-Daten, Ranking, Tastatur-Navigation
This commit is contained in:
17
apps/frontend/src/hooks/useServices.ts
Normal file
17
apps/frontend/src/hooks/useServices.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import type { Service } from "@launchpad/shared";
|
||||
|
||||
async function fetchServices(): Promise<Service[]> {
|
||||
const res = await fetch("/api/services");
|
||||
if (!res.ok) {
|
||||
throw new Error(`Dienste konnten nicht geladen werden (HTTP ${res.status})`);
|
||||
}
|
||||
return res.json();
|
||||
}
|
||||
|
||||
export function useServices() {
|
||||
return useQuery({
|
||||
queryKey: ["services"],
|
||||
queryFn: fetchServices,
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user