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

81
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
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