export type GetApiApiV1PageRenderHTMLUriArgs = {uri: string, host_id?: string | undefined, mode?: string | undefined}; export type GetApiApiV1PageRenderHTMLUriOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * Render page as raw HTML * * GET /api/v1/page/renderHTML/{uri} */ export const getApiApiV1PageRenderHTMLUri = async (args: GetApiApiV1PageRenderHTMLUriArgs, options: GetApiApiV1PageRenderHTMLUriOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/html") if (args.host_id != null) query.append("host_id", String(args.host_id)) if (args.mode != null) query.append("mode", String(args.mode)) const url = `${baseUrl.replace(/\/+$/, '')}/api/v1/page/renderHTML/${encodeURIComponent(String(args.uri))}${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 res.blob() };