export type GetApiFoodMenuItemsIdNutritionLabelArgs = {id: number, defaultCss?: boolean | undefined, showOptionalNutrients?: boolean | undefined, showZeroValues?: boolean | undefined, showIngredients?: boolean | undefined}; export type GetApiFoodMenuItemsIdNutritionLabelOptions = {baseUrl?: string | undefined, apiKeyScheme?: string | undefined, fetch?: typeof fetch | undefined}; /** * Menu Item Nutrition Label Widget * * GET /food/menuItems/{id}/nutritionLabel */ export const getApiFoodMenuItemsIdNutritionLabel = async (args: GetApiFoodMenuItemsIdNutritionLabelArgs, options?: GetApiFoodMenuItemsIdNutritionLabelOptions) => { 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.defaultCss != null) query.append("defaultCss", String(args.defaultCss)) 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${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() };