export type GetApiCountriesCountryArgs = {country: string, Authorization: string}; export type GetApiCountriesCountryOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Get a single country * * GET /countries/{country} */ export const getApiCountriesCountry = async (args: GetApiCountriesCountryArgs, options?: GetApiCountriesCountryOptions) => { const {baseUrl = "http://127.0.0.1:8443", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.Authorization != null) headers.set("Authorization", String(args.Authorization)) const url = `${baseUrl.replace(/\/+$/, '')}/countries/${encodeURIComponent(String(args.country))}${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 };