Why this lesson matters
Understand request and response and use it correctly in an App Router project. Route Handlers expose HTTP contracts from the App Router. External API calls need explicit methods, status codes, validation, timeouts and server-side secret handling.
How to reason about it
- For Request and Response, the outcome to verify is: Keep the Route Handler contract explicit in method, status and body.
- In Request and Response, keep this failure controlled: Using Route Handlers as thin proxies with no validation or timeout simply moves an unreliable external contract behind your URL.
- Request and Response practice target: Create a GET health handler and one external-service adapter that validates the upstream response and maps failures to a stable status.
Practical walkthrough
In the Request and Response walkthrough: Keep the Route Handler contract explicit in method, status and body.
app/api/health/route.tstypescript
export async function GET() {
return Response.json({ ok: true }, { status: 200 });
}Practice it yourself
Request and Response exercise
Create a GET health handler and one external-service adapter that validates the upstream response and maps failures to a stable status.
- Record the expected result before execution
- Test one valid path and one lesson-specific failure path
- Explain in two lines which boundary owns the decision
