Answer the question
In order to leave comments, you need to log in
How to add an intermediate handler before res.json() in ExpressJs?
Hello, I have the task of counting how long the request was executed, and logging the request and response, and for this I need to perform logging before answering the user and calculate how long the request was executed.
How to make it more and more beautiful, add an intermediate handler not at the beginning of the application, but at the end?
This is how I plan to do the first timestamp:
app.use((req, res, next) => {
req.startTimer = Date.now()
next()
})
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question