export type GetApiFoodMenuItemsIdNutritionLabelPngArgs = {id: number, showOptionalNutrients?: boolean | undefined, showZeroValues?: boolean | undefined, showIngredients?: boolean | undefined}; export type GetApiFoodMenuItemsIdNutritionLabelPngOptions = {baseUrl?: string | undefined, apiKeyScheme?: string | undefined, fetch?: typeof fetch | undefined}; /** * Menu Item Nutrition Label Image * * GET /food/menuItems/{id}/nutritionLabel.png */ export const getApiFoodMenuItemsIdNutritionLabelPng = async (args: GetApiFoodMenuItemsIdNutritionLabelPngArgs, options?: GetApiFoodMenuItemsIdNutritionLabelPngOptions) => { 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 (args.showOptionalNutrients != null) query.append("showOptionalNutrients", String(args.showOptionalNutrients)) if (args.showZeroValues != null) query.append("showZeroValues", String(args.showZeroValues)) if (args.showIngredients != null) query.append("showIngredients", String(args.showIngredients)) if (apiKeyScheme !== undefined) headers.set("x-api-key", apiKeyScheme) const url = `${baseUrl.replace(/\/+$/, '')}/food/menuItems/${encodeURIComponent(String(args.id))}/nutritionLabel.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() };