Challenge - 5 Problems
Edge API Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ service_behavior
intermediate2:00remaining
What is the output when an Edge Function calls an external API and the API returns a 404 status?
Consider an Edge Function that fetches data from an external API endpoint which does not exist, resulting in a 404 HTTP status. What will the Edge Function's fetch call return?
Supabase
export async function handler(request) { const response = await fetch('https://api.example.com/nonexistent'); return new Response(JSON.stringify({ status: response.status }), { status: 200 }); }
Attempts:
2 left
💡 Hint
Think about how fetch handles HTTP errors like 404.
✗ Incorrect
The fetch API resolves successfully even if the HTTP status is 404. The response object contains the status code 404, so the Edge Function returns {"status":404}.
❓ Architecture
intermediate2:00remaining
Which architecture best supports calling multiple external APIs in parallel from an Edge Function?
You want to call three different external APIs from a Supabase Edge Function and combine their results. Which approach is best to minimize total response time?
Attempts:
2 left
💡 Hint
Think about how to run multiple async calls at the same time.
✗ Incorrect
Using Promise.all runs all fetch calls in parallel, reducing total wait time compared to sequential calls.
❓ security
advanced2:00remaining
What is the safest way to store and use API keys when calling external APIs from Supabase Edge Functions?
You need to call an external API that requires an API key. How should you handle the API key in your Edge Function to keep it secure?
Attempts:
2 left
💡 Hint
Think about where sensitive data should be stored to avoid exposure.
✗ Incorrect
Environment variables keep secrets out of source code and client requests, protecting API keys from exposure.
❓ Configuration
advanced2:00remaining
Which code snippet correctly handles JSON response parsing and errors when calling an external API from an Edge Function?
Choose the code snippet that safely fetches JSON data from an external API and handles possible errors without crashing.
Attempts:
2 left
💡 Hint
Consider error checking and async handling.
✗ Incorrect
Option B checks if the response is OK and uses try-catch to handle errors, preventing crashes.
✅ Best Practice
expert2:00remaining
What is the best practice to avoid cold start delays when calling external APIs from Supabase Edge Functions?
Cold starts can slow down Edge Functions. Which approach helps reduce cold start latency when your function calls external APIs?
Attempts:
2 left
💡 Hint
Think about what affects startup time and how caching helps.
✗ Incorrect
Minimal code reduces startup time, and caching API responses avoids repeated slow calls, improving performance.