Full Stack Web Development
Step 12 / 21150 min

Express & REST APIs

Backend & APIs

Explanation

Express helps you design REST endpoints for create/read/update/delete with middleware and clear route structure.

Code example

javascript
import express from "express";

const app = express();
app.use(express.json());

const skills = [{ id: "1", name: "HTML" }];

app.get("/api/skills", (_req, res) => res.json(skills));
app.post("/api/skills", (req, res) => {
  const skill = { id: String(Date.now()), name: req.body.name };
  skills.push(skill);
  res.status(201).json(skill);
});

app.listen(4000);

Helpful resources

Exercise

Build a REST API for skills with GET list, GET by id, POST, and DELETE endpoints.