The Life Starter
0 of 6 complete0%
Course Library · Lesson 3 of 6
Digital · Guided lesson

Make a read-only request and inspect status

About 31 minutes · 6 reading + 25 practice and checks
Time includes reading, practice, and questions. Extra videos or further study are optional.
See this course’s project requirements

A tested local API-response viewer with a request contract, validation rules, six response cases and an honest integration handoff.

Keep your working files in your own notebook or software. Save a private description, checklist, and work link in My Proof.

What to include

  • Request/response contract with limits.
  • Type and status observations.
  • Working local viewer.
  • Explicit empty/error/validation behavior.
  • Six-case test matrix and README.

Review and revise

Use these criteria to check your work and choose what to improve.

  • Fields and types are understood.
  • Failures do not show stale results.
  • All six cases behave as described.
  • Simulation and live-integration limits are explicit.
Open the full course project
Want more background?
Before you begin

The idea in everyday life

Build a read-only viewer for a fictional library-hours API contract.

The idea

Await pauses this function until its promise settles; it does not validate the response.

Follow along

Make a read-only request and inspect status — guided practice

Use an asynchronous response and explain simulation versus live transport.

Save api-viewer.html from the download and open it in a modern browser. Open its source in a text editor. The complete original file supplies every fixture and function. It simulates GET /hours locally; it does not contact a real library. Reload after edits; restore the supplied file before each lesson unless told otherwise.

  1. 1. Trace the call

    Find await mockRequest in loadHours and read the three arguments.

    You should see: It passes /hours, GET and the chosen case.

    The adapter replaces transport while preserving a response-processing exercise.

  2. 2. Inspect successful status

    Run success and read the trace beneath the list.

    You should see: GET /hours -> 200.

    Status is separate from body content.

  3. 3. Try an unsupported path

    In source change only the call path to /unknown, save and reload. Click Load hours.

    You should see: The trace shows 404 and no branch list.

    The adapter checks the contract before returning a successful body.

  4. 4. Restore

    Change the path back to /hours. Record that live code would call fetch against an authorized endpoint and follow its CORS/authentication rules.

    You should see: Success returns again; the project remains an honest local simulation.

    No credential or cross-origin workaround is part of this exercise.

Now change one thing

In this adapter, GET /unknown returns which status number?

Your work

What to finish

A traced request with one deliberate path failure.

Common mistake

Watch for this

Saying the simulator contacted a real service or tested real network availability.

How can I tell I understand it?

Complete the changed case, explain your result, and pass the three application checks.

Try 3 questions

Quick knowledge check

Answer all 3 questions. Get at least 2 right and the lesson completes automatically.

Not yet passed

You’ll get an explanation for each answer. Signed in? Your results save to your account.

1A request promise resolves with HTTP 500. Has the application necessarily succeeded?
2A local mock passes all tests. Which claim is justified?
3A real endpoint requires an API key. Where should a learner avoid putting a secret?
0 of 3 answeredApply the lesson to a short question, then review the explanation.
3
Finish this lesson

Pass the check. We’ll save the progress.

Answer all 3 questions above and get at least 2 right. You can review the explanations and try again.

Go to the knowledge check
Optional course overview video · same video as Lesson 1
freeCodeCamp.orgAPIs for Beginners - How to use an API (Full Course / Tutorial)YouTube
Optional course overview

APIs for Beginners - How to use an API (Full Course / Tutorial)

From freeCodeCamp.org. Watch here or open it on YouTube .

Optional course overview. Follow the written steps below at your own pace.
Tools, templates, and lesson sources

Tools and templates

Tools open in a new tab so you can keep your place here.

Sources and further reading

Explore the references behind this lesson.

MDN: Using the Fetch API
Source & access notes · checked 2026-09-12

Opened and inspected on 2026-09-12: Responses, promises and explicit HTTP status checks.

Access: Free public web page; no paid enrollment required.

Reuse: Public reference; link only. LifeStarter prose, exercises and files are independently authored.

MDN: HTTP response status codes
Source & access notes · checked 2026-09-12

Opened and inspected on 2026-09-12: 200, 404 and server-error categories.

Access: Free public web page; no paid enrollment required.

Reuse: Public reference; link only. LifeStarter prose, exercises and files are independently authored.

Report a problem with this lesson

Tell us what went wrong. Please leave out personal information and private project contents.

No sign-in needed.