I've encountered an issue with a middleware function that is triggering after the main function finishes execution from the endpoint. Here's the code for my middleware:
export const someMiddleware = async (
req: Request,
res: Response,
next: NextFunction
) => {
res.on("finish", () => {
// handling logic here
})
next();
}
I'm facing difficulty in accessing the data sent to the client within the on()
callback of this middleware. Can anyone guide me on how to retrieve the response body sent to the client in this scenario?
Appreciate any assistance provided!