export type GetApiRecipesIdTasteWidgetArgs = {id: number, normalize?: boolean | undefined, rgb?: string | undefined}; export type GetApiRecipesIdTasteWidgetOptions = {baseUrl?: string | undefined, apiKeyScheme?: string | undefined, fetch?: typeof fetch | undefined}; /** * Recipe Taste by ID Widget * * GET /recipes/{id}/tasteWidget */ export const getApiRecipesIdTasteWidget = async (args: GetApiRecipesIdTasteWidgetArgs, options?: GetApiRecipesIdTasteWidgetOptions) => { const {baseUrl = "https://api.spoonacular.com", fetch: fetchFn = fetch, apiKeyScheme} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "text/html") if (args.normalize != null) query.append("normalize", String(args.normalize)) if (args.rgb != null) query.append("rgb", String(args.rgb)) if (apiKeyScheme !== undefined) headers.set("x-api-key", apiKeyScheme) const url = `${baseUrl.replace(/\/+$/, '')}/recipes/${encodeURIComponent(String(args.id))}/tasteWidget${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() };