Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

108
Vistas
express middleware after response

I've had a problem with middleware function which is launching on finish execution of main function from endpoint. Here is my middleware:

export const someMiddleware = async (
    req: Request,
    res: Response,
    next: NextFunction
) => {
    res.on("finish", () => {
        //here
    })
    next();
}

I am having trouble getting the data that was sent to the client from the request handled by this middleware, can anyone tell me how to get the response body that is sent to the client inside the on () callback?

Thanks for any help!

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

This is quite painful with Express. One way to handle this is to override the send and write functions, and capture the output this way.

It's not impossible to do this, other middlewares like a gzip middleware would do this too.

A frustration with this limitation has eventually lead me to write my own framework, so I get where you are coming from.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda