This question runs in a pre-configured Salesforce environment - no personal connection required.

Search for products using the DummyJSON API and return a list of product titles that match the search query. Make an HTTP GET request to https://dummyjson.com/products/search?q={query} where {query} is the search term. The API returns a JSON response with a products array containing product objects with fields like title, description, price, etc. Extract only the title field from each product. Return an empty list if the query is null, empty, if no products are found, or if an error occurs.

Examples:

Input: query = "phone" Output: ["iPhone 9", "iPhone X", "Samsung Universe 9", ...] Explanation: Returns titles of all products containing "phone" in their data Input: query = "laptop" Output: ["MacBook Pro", "Samsung Galaxy Book", ...] Explanation: Returns titles of products matching "laptop" search Input: query = "" Output: [] Explanation: Empty query returns empty list Input: query = null Output: [] Explanation: Null query returns empty list
Apex Code Editor

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 account

How 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

🏆 #CodeEveryDay Feb 2026

Contest runs February 1 - 28. Complete challenges to climb the leaderboard!

Points are calculated for challenges completed during the contest period.