Add external data and persistence

Use a public API as enhancement while keeping core tracking usable on failure.

Difficulty
beginner
Time
55 minutes
Last verified
9/21/2026

What you will build

Use a public API as enhancement while keeping core tracking usable on failure.

Understand the idea first

Use a public API as enhancement while keeping core tracking usable on failure.

Build it step by step

try {
  const tip = await loadDailyTip();
  showTip(tip);
} catch {
  showTip('今天先完成一小步。');
}
saveSessions(state.sessions);
  1. Open the previous project and record its result.
  2. Type the example and complete: Simulate timeout, 500, broken JSON, and offline; adding a record must still work.
  3. Change one input, predict, then verify.
  4. Create and repair: An enhancement API must not become a single point of failure.

Read the important lines

  • Use a public API as enhancement while keeping core tracking usable on failure.
  • Read input, processing, and output separately.
  • Verify another input and an edge case.

Common mistakes and what to check

SymptomWhat to check
Unexpected resultAn enhancement API must not become a single point of failure.
Nothing changesSave, verify paths, and read the first relevant Console error.

Practice without copying

Simulate timeout, 500, broken JSON, and offline; adding a record must still work.

Check the answer after you try

Rebuild and explain the decisions. Check: An enhancement API must not become a single point of failure.

Completion check

  • I produced the required visible result
  • I can explain the input, processing, and output
  • I tested normal, edge, and failure cases

Your privacy choices

Necessary storage is always on. Optional analytics and support services load only after consent.