export type GetApiHardinessMapArgs = {key: string, species_id?: number | undefined}; export type GetApiHardinessMapOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Get hardiness map (HTML image view) * * GET /hardiness-map */ export const getApiHardinessMap = async (args: GetApiHardinessMapArgs, options?: GetApiHardinessMapOptions) => { const {baseUrl = "https://perenual.com/api", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "text/html") if (args.key != null) query.append("key", String(args.key)) if (args.species_id != null) query.append("species_id", String(args.species_id)) const url = `${baseUrl.replace(/\/+$/, '')}/hardiness-map${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.text() };