ソースコード
const express = require('express')
const app = express()
const port = 3000
var count = 0;
app.use(function(req,res,next){
count++;
console.log(count);
next();
})
app.use(function(req,res,next){
count++;
console.log(count);
next();
})
app.use(function(req,res,next){
count++;
console.log(count);
next();
})
app.get('/', (req, res) => {
res.send(`Hello World! ${count}`)
})
app.listen(port, () => {
console.log(`Example app listening at http://localhost:${port}`)
})
結果
C:\workspace\01_Project\20_appusetest>node app.js
Example app listening at http://localhost:3000
1
2
3