Command Palette

Search for a command to run...

Hectal
Phase 0: Start Here: AI Features Through a Frontend Developer's Eyes
AI Frontend · Exercise 1 of 5Next
Beginner

Show the Answer

The route /api/chat is ready and answers with JSON in the usual chat shape. When the button #ask is clicked, send a POST to /api/chat and put the model's reply into the paragraph #answer.

The request body is already written for you. The reply text is at data.choices[0].message.content.

What Check tests

  1. Before the click, #answer is empty
  2. After clicking #ask, #answer shows the model's reply
  3. The code calls fetch with /api/chat

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.