Build HTTP APIs with routing, middleware, validation, controllers, and error handling.
Lessons
Use res.send, res.json, res.status, res.redirect, and res.end correctly.
Response Methods 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());
app.get('/api/lessons', (req, res) => {
res.json([{ slug: 'express-routing', title: 'Express Routing' }]);
});
app.post('/api/lessons', (req, res) => {
res.status(201).json({ created: true, title: req.body.title });
});
app.listen(process.env.PORT || 3000);Practice the Response Methods example in a small scratch file, then explain what changed and why.