One handler run per request
Watch how many times the handler runs when the client sends two requests.
const http = require('node:http');let count = 0;const server = http.createServer((req, res) => { count++; console.log('handler ' + count + ': ' + req.url); res.end('hi ' + count);});server.listen(0, async () => { const { port } = server.address(); const a = await fetch(`http://localhost:${port}/a`); console.log('client got ' + await a.text()); const b = await fetch(`http://localhost:${port}/b`); console.log('client got ' + await b.text()); server.close();});1. Predict the output
Tap the lines in the order you think they print.
- 1…
- 2…
- 3…
- 4…