export type GetApiPicturesCatOptions = {baseUrl?: string | undefined, LegacyAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Example of a parameter in URL * * GET /pictures/{cat} */ export const getApiPicturesCat = async (options?: GetApiPicturesCatOptions) => { const {baseUrl = "http://localhost:3000", fetch: fetchFn = fetch, LegacyAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "image/png") if (LegacyAuth !== undefined) headers.set("X-App-Token", LegacyAuth) const url = `${baseUrl.replace(/\/+$/, '')}/pictures/${encodeURIComponent(String(args.cat))}${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() };