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
- After the 429,
#askis disabled and#errorsaysTry again in 1 s - No answer is shown while the limit applies
- After the wait,
#askis enabled again and#erroris empty - 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.