T9 APIs · Lesson 5
Games: Requests and responses
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 46 items in this lesson.
1 / 22
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.post("/r", (req, res) => res.send(String(req.is("json"))));
const server = app.listen(3000, async () => {
const r = await fetch("http://localhost:3000/r", { method: "POST", headers: { "Content-Type": "application/json" }, body: '{"v":1}' });
console.log(await r.text());
server.close();
});
END
node app.js