T9 APIs · Lesson 1
Games: HTTP and REST
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 runs in the shop's folder, where api.js holds the lesson's gauges API (boiler 95 and pump 40; POST to /gauges, GET, PUT and DELETE on /gauges/NAME). What does it print?
cat > app.js <<'END'
const server = require("./api");
server.listen(3000, async () => {
const r = await fetch("http://localhost:3000/gauges", { method: "POST", body: JSON.stringify({ name: "fan", value: 20 }) });
console.log(r.status, r.headers.get("location"));
server.close();
});
END
node app.js