export type GetApiImagesRemoteArgs = {imageUrl: string}; export type GetApiImagesRemoteOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Gets a remote image. * * GET /Images/Remote */ export const getApiImagesRemote = async (args: GetApiImagesRemoteArgs, options?: GetApiImagesRemoteOptions) => { const {baseUrl = "http://localhost", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "image/*") if (args.imageUrl != null) query.append("imageUrl", String(args.imageUrl)) const url = `${baseUrl.replace(/\/+$/, '')}/Images/Remote${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() };