export type GetApiPageAreasPageArgs = {page: 'cases' | 'testing' | 'deaths' | 'vaccinations' | 'healthcare', Accept: 'application/json', 'Accept-Encoding'?: ('deflate' | 'gzip' | 'br') | undefined}; export type GetApiPageAreasPageOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Page areas * * GET /page_areas/{page} */ export const getApiPageAreasPage = async (args: GetApiPageAreasPageArgs, options?: GetApiPageAreasPageOptions) => { const {baseUrl = "https://api.coronavirus.data.gov.uk/generic", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") if (args.Accept != null) headers.set("Accept", String(args.Accept)) if (args['Accept-Encoding'] != null) headers.set("Accept-Encoding", String(args['Accept-Encoding'])) const url = `${baseUrl.replace(/\/+$/, '')}/page_areas/${encodeURIComponent(String(args.page))}${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 (await res.json()) as unknown };