Threw nodejs,I have a problem in calculating express api response time.
instead of using middlewares like morgan
and winston
using app.use()
. I need a way to log response time inside api scope and send it as a response.
like :
app.post('/api', function (req: Request, res:Response) {
...
res.json({responseTime,data})
})
I have tried response-time
package and stackoverflow question solutions but they were not helpful.
In fast responses that take less than 100ms, I see different response time in postman and my node server console.(e.g. postman:130ms , node server: 3ms)
how can I calculate the response time accurately?