Command Palette

Search for a command to run...

Hectal
Phase 3: Stop, Retry and Failure
AI Frontend · Exercise 4 of 5 PreviousNext
Intermediate

A Countdown for a Rate Limit

The first call to /api/chat is refused with 429 and Retry-After: 1. The second works.

When #ask is clicked and the answer is a 429, disable #ask and show Try again in 1 s in #error. After that second passes, enable the button again and clear #error. A normal answer goes into #answer.

What Check tests

  1. After the 429, #ask is disabled and #error says Try again in 1 s
  2. No answer is shown while the limit applies
  3. After the wait, #ask is enabled again and #error is empty
  4. The next click gets the answer

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.