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

227
Views
How to stream a data stream to client from Node.js server

My Node.js server receives a stream of data from an external API. I serve my client after receiving the data completely. Like this,

async function getFile(req, res) {
    const { id } = req.body;
    const file = await get(process.env.FILE_API_URL + id);

    res.send(file);
}

But instead of waiting to receive the whole stream, I would like to stream it to the client as soon as I have some data. Kind of like this,

function getFile(req, res) {
    const { id } = req.body;
    const stream = get(process.env.FILE_API_URL + id);

    stream.on('data', (data) > {
        res.write(data);
    });

    stream.on('end', res.end);
}

How can I implement this?

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!