export type GetApiOgcArgs = {f?: string | undefined}; export type GetApiOgcOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * Landing page of this API * * GET /ogc */ export const getApiOgc = async (args: GetApiOgcArgs, options: GetApiOgcOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.f != null) query.append("f", String(args.f)) const url = `${baseUrl.replace(/\/+$/, '')}/ogc${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "GET", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };