export type GetApiFoodProductsIdNutritionWidgetPngArgs = {id: number}; export type GetApiFoodProductsIdNutritionWidgetPngOptions = {baseUrl?: string | undefined, apiKeyScheme?: string | undefined, fetch?: typeof fetch | undefined}; /** * Product Nutrition by ID Image * * GET /food/products/{id}/nutritionWidget.png */ export const getApiFoodProductsIdNutritionWidgetPng = async (args: GetApiFoodProductsIdNutritionWidgetPngArgs, options?: GetApiFoodProductsIdNutritionWidgetPngOptions) => { const {baseUrl = "https://api.spoonacular.com", fetch: fetchFn = fetch, apiKeyScheme} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "image/png") if (apiKeyScheme !== undefined) headers.set("x-api-key", apiKeyScheme) const url = `${baseUrl.replace(/\/+$/, '')}/food/products/${encodeURIComponent(String(args.id))}/nutritionWidget.png${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() };