Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

178
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!