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

639
Views
axios response.data.pipe not a function

I'm using axios to download image in nodejs. I've added the following the code

const axios = require("axios").default;
const fs = require("fs");

const url =
  "https://images.pexels.com/photos/11431628/pexels-photo-11431628.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=750&w=1260";

async function downloadImage() {
  try {
    const { data } = await axios.get(url);
    data.pipe(fs.createWriteStream("sample.jpg"));
  } catch (error) {
    console.log(error);
  }
}

downloadImage();

But I get the following error

TypeError: data.pipe is not a function

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

.pipe() can only be used on streams. To get axios response in streams, add a config object with responseType:'stream'

    const { data } = await axios.get(url, { responseType: "stream" });
    data.pipe(fs.createWriteStream("sample.jpg"));

about 4 years ago · Juan Pablo Isaza Report
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!