AI Frontend · Exercise 1 of 5Next
Intermediate
Show the Tool at Work
The route /api/chat has one tool, lookupOrder, which takes about a third of a second. The page already has a button #ask and a paragraph #tool, and it already finds the tool part in part.
Fill #tool from the part's state. While the tool is running (input-available) it must say Looking up your order…. When the result is there (output-available) it must say ORD-1042: Masala chai 250 g, shipped. Never read part.output before it exists.
What Check tests
- Before the click,
#toolis empty - While the tool runs,
#toolsaysLooking up your order… - When the tool is done,
#toolshows the order - The code switches on the part's state
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.