Build HTTP APIs with routing, middleware, validation, controllers, and error handling.
Lessons
Read JSON and form bodies into req.body safely.
Parsing Request Bodies is easiest to learn by reading the example, changing it, and observing the result.
import express from 'express';
const app = express();
app.use(express.json()); // JSON bodies
app.use(express.urlencoded({ extended: true })); // HTML form bodies
app.post('/api/lessons', (req, res) => {
const { title } = req.body;
res.status(201).json({ title, created: true });
});
app.listen(3000);Practice the Parsing Request Bodies example in a small scratch file, then explain what changed and why.