Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

109
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda