This question runs in a pre-configured Salesforce environment - no personal connection required.
Call the DummyJSON recipes API to fetch a recipe by ID and return its list of ingredients. The DummyJSON API provides realistic test data for recipes. You will make an HTTP GET request to the endpoint https://dummyjson.com/recipes/{id} where {id} is the recipe ID. The API returns a JSON response containing recipe details including an ingredients array of strings. Your task is to extract and return this list of ingredients. If the recipe ID is invalid, null, or if an error occurs, return an empty list.
Examples:
Input: recipeId = 1
Output: ["Eggs", "Milk", "Butter", "Vanilla Extract", "Sugar", "Flour"]
Explanation: Returns the ingredients for recipe 1
Input: recipeId = 2
Output: ["Chicken Breast", "Olive Oil", "Garlic", "Lemon", "Thyme"]
Explanation: Returns the ingredients for recipe 2
Input: recipeId = 9999
Output: []
Explanation: Invalid recipe ID returns empty list
Input: recipeId = null
Output: []
Explanation: Null input returns empty list
Welcome to Lightning Challenge!
Create an Account
Sign up to track your progress, earn points, and compete with others. Your solutions will be saved automatically.
Create accountHow It Works
- • Write your solution in the code editor
- • Connect your Salesforce org to test
- • Submit to check if your solution passes
- • Use hints if you get stuck
Contest Alert
Contest runs March 3 - 31. Complete challenges to climb the leaderboard!
Points are calculated for challenges completed during the contest period.