AI Frontend · Exercise 5 of 5 Previous
Advanced
Retry Only What Can Work
Write askWithRetry(). The route fails with 503 twice and then answers. #ask should show the answer in #answer and the number of requests it took in #attempts as Attempts: 3.
Retry only retryable failures (408, 429 and 5xx), at most 3 retries, waiting 100 * 2 ** attempt ms before each retry. #bad asks a question the route rejects with 400: it must not be retried. Show Mitra could not answer. in #error and Attempts: 1.
What Check tests
#askretries the two 503s and shows the answer andAttempts: 3#badis not retried:Attempts: 1and the error message- The code waits between tries (it uses
sleep)
Stuck? One hint at a time
The solution unlocks after your first Check. Try first: that is where the learning happens.
Runs in your browser. Your code is saved here.
Your page
Press Run to see the page.
Console
Nothing logged yet.