Concept
Headers carry metadata: what format the body is in, how long to cache, who the caller is. Content-Type on both request and response is what lets each side parse the body at all.
The tutor works through these with you, in conversation and code. A session ends when you have shown them, not when a video does.
A few lines that show Headers and content types doing its job.
app.post("/orders", async (req, reply) => {
if (!req.headers["content-type"]?.startsWith("application/json")) {
return reply.code(415).send({ error: "send JSON" });
}
const order = await orders.create(req.body);
return reply
.code(201)
.header("location", "/orders/" + order.id)
.header("cache-control", "no-store")
.send(order);
});Sending JSON without Content-Type: application/json. Some clients then treat the body as text, and frameworks on the receiving end leave req.body undefined.
Your roadmap puts these before Headers and content types, unless you already know them.
Once a session shows you understand Headers and content types, it comes back for review. Each review takes a minute and tells the memory model how well you still know it.
Topics that build on Headers and content types.