T9 APIs · Lesson 4
Games: Middleware
Choose the right option, fill in the blanks, write small pieces of code and fix broken ones. Code runs in a safe box inside this page.
Solved 0 of 45 items in this lesson.
1 / 21
This program is an Express app and its own client, run in the shop's folder. What does it print?
cat > app.js <<'END'
const express = require("express");
const app = express();
app.use((req, res, next) => { res.locals.who = "gate"; next(); });
app.get("/", (req, res) => res.send(res.locals.who));
const server = app.listen(3000, async () => {
const r = await fetch("http://localhost:3000/");
console.log(await r.text());
server.close();
});
END
node app.js