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

179
Vistas
How to pass the response in stream in GET method

Hi I am trying to pass the below data in stream form as the normal response is taking too long because of conversion of images into base64data

Looking at various similar issues I tried changing the response to pipe() but still facing issues

Please see below code for reference

Hence can you please tell me how to pass the response in stream form and check it in postman

router.js

router.get("/users/data/expand/:nid", async (req, res) => {
  var idselected = req.params.nid;
  var dir = "images";
  try {
    const checkData = await user.findOne({ user_id: idselected });

    let receivedFile = await Promise.all(
      checkData.attachments.flatMap(async element => {
        let files = await readDirectory(dir);
        return await Promise.all(
          files.map(filename => {
            filename = element;
            return readFile(filename)
          })
        );
      })
    );
    const returnUser = new User({
      user_id: checkData.user_id,
      attachments: receivedFile
    });
    let savedUser = await returnUser.save();
    res.status(201).pipe(savedUser); 
  } catch (e) {
    res.status(500).send(e);
  }
});
about 4 years ago · Juan Pablo Isaza
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