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

210
Views
Cómo recibir errores al descargar un archivo usando axios

Mi código:

resto cliente:

 return axios.get(url, { responseType: 'arraybuffer' });

respuesta de manejo:

 const link = document.createElement('a'); link.href = window.URL.createObjectURL(new Blob([response.data])); link.target = "_blank"; link.click();

funciona bien si no hay errores en el lado del servidor. Sin embargo, cuando hay un error en la API del servidor, no obtengo detalles, debido a que el tipo de respuesta es arraybuffer .

 .catch((error) => { dispatch(showError("An Error Occured", error)); //error does not contain the expected details });

Intenté no configurar el tipo de arraybuffer, en lugar de usar TextDecoder, sin embargo, el pdf resultante parece estar dañado (pantalla vacía).

¿Cómo puedo modificar la configuración existente para poder recibir detalles en caso de que ocurra un error?

Editar: Solución: OK, lo tengo, puedo decodificar la información del error de error.data:

 var data:any = JSON.parse(new TextDecoder().decode(error.data));

y luego use el código de error y el mensaje.

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!