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

Take a character ID and return their homeworld name using the Star Wars API. Make two API calls: first to get the character data, then to get their homeworld information.

Accept character IDs from 1-10 (valid Star Wars characters). Make a GET request to https://swapi.info/api/people/{characterId}, extract the homeworld URL from the character data, make a second GET request to the homeworld URL, and return the planet name from the homeworld data. Handle error cases (invalid IDs, API failures) by returning null.

Examples:

Input: characterId = 1 Output: "Tatooine" Explanation: Luke Skywalker's homeworld is Tatooine Input: characterId = 5 Output: "Alderaan" Explanation: Princess Leia's homeworld is Alderaan Input: characterId = 0 Output: null Explanation: Invalid character ID, return null
Apex Code Editor

Welcome to Lightning Challenge!

How It Works

  • • Write your solution in the code editor
  • • This challenge runs without connecting your own org
  • • Submit to check if your solution passes
  • • Use hints if you get stuck

Contest Alert

🏆 #CodeEveryDay July 2026

Contest runs July 1 - 31. Complete challenges to climb the leaderboard!

Only the 31 daily challenges shown during this contest count toward points. Earlier dailies don't carry over.

Wally can't hear you

Please sign in to access the AI Assistant

Sign In