← Back to Webstore Course

Week 6: Data Fetching, Caching, and Validation

This week builds reliability habits in data-heavy ecommerce flows. The student learns to keep UI data fresh and API boundaries safe.

Learning Objectives

  • Understand mutation, revalidation, and stale data risks.
  • Design consistent API validation and error contracts.
  • Reduce UI inconsistency after write operations.
  • Document expected behavior for edge-case inputs.

Detailed Topics

1. Caching and Invalidation Mental Model

Teach the student to explicitly define what must refresh after each mutation: cart totals, stock, promotions, account summaries.

2. Validation at the API Boundary

Validate structure, required fields, value ranges, and contextual authorization. Reject invalid requests before business logic runs.

3. Error Contracts for Frontend Stability

Standardize error shape so components can handle failures predictably without brittle condition checks.

Pair Session Plan (90 Minutes)

  1. Find one stale-data bug in cart or account flow.
  2. Patch cache strategy and verify post-mutation behavior.
  3. Harden one API route input contract.
  4. Confirm consistent error payload handling in UI.

Independent Ticket

Submit one PR that includes both a cache consistency fix and an API validation improvement with documented outcomes.

Mentor Checkpoint

  • Student predicts which keys require revalidation.
  • Student rejects malformed input with useful messages.
  • Student demonstrates stable UI behavior after failures.
← Previous: Week 5 Next: Week 7 →