Files
wtr/lib/location-api.ts

10 lines
521 B
TypeScript

import type { Language } from "@/lib/i18n";
import type { LocationSearchResult } from "@/types/location";
export async function fetchLocations(query: string, language: Language, signal?: AbortSignal): Promise<LocationSearchResult[]> {
const params = new URLSearchParams({ query, language });
const response = await fetch(`/api/locations/search?${params}`, { signal });
if (!response.ok) throw new Error("Location search is temporarily unavailable.");
return response.json() as Promise<LocationSearchResult[]>;
}