Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

84
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda