Skip to content

Set any variables in middlewares #5080

Answered by OmBayus
sedri02 asked this question in Q&A
Discussion options

You must be logged in to vote
app.use((req, res, next) => {
  req.id=1;
  next();
});

app.get("/",(req,res)=>{
  console.log(req.id)
})

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by sedri02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
2 participants