Command Palette

Search for a command to run...

Hectal
Phase 1: Calling a Model over HTTP
AI Frontend · Exercise 5 of 6 PreviousNext
Intermediate

Time Limit and Try Again

The first request to this route takes 600 ms; later ones are instant. Add a time limit of 200 ms with AbortSignal.timeout(200). When it fires, show Mitra is taking too long. Please try again. in #error and show the #retry button (it starts hidden). Other failures show Cannot reach Mitra. Check your connection.

Clicking #retry asks again. On success show the answer in #answer, clear #error and hide #retry again.

What Check tests

  1. The first (slow) request ends with Mitra is taking too long. Please try again. and a visible #retry
  2. Clicking #retry shows the answer, clears the error and hides #retry
  3. The code uses AbortSignal.timeout

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.