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

82
Views
Converting response to arraybuffer

I am trying to convert a response to arraybuffer with axios. I keep getting an error message: "TypeError: response.arrayBuffer is not a function". Below is the code I wrote and suggestion on what I am doing wrong or a solution to this error.

 axios
      .post("http://127.0.0.1:8000/api/file-api", formData, {
        headers: {
          "Content-Type": "application/x-www-form-urlencoded",
          'Access-Control-Allow-Origin':'http://localhost:8080',
          'Access-Control-Allow-Credentials': 'true', 
          'Authorization': `bearer ${token}`
          
        },
      })
      .then((response) => response.arrayBuffer())
      .then((res) => {
        const arrayBuffer = res.arrayBuffer();
        const objUrl = window.URL.createObjectURL(new Blob([arrayBuffer]));
        return objUrl;

        

        
      })
      .catch((err) => {
        console.log(err);
      });
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

After reading this post [Axios vs. fetch(): Which is best for making HTTP requests?][1],

[1]: https://blog.logrocket.com/axios-vs-fetch-best-http-requests/#:~:text=Axios%20automatically%20transforms%20the%20data,info%20on%20what%20the%20response. and then the comment by @Bravo, I notice using axios may not be able to provide an arraybuffer as a responseType. In the case of arraybuffer, it is best to use fetch.

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!