0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Express app.use 呼び出しタイミング

Posted at

ソースコード

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

image.png

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?