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

138
Views
Descargue un archivo JSON de una respuesta JSON en el navegador

Mi backend está enviando una respuesta JSON que contiene datos. Me gustaría almacenar esos datos en un archivo y preguntarle al usuario si quiere descargarlo.

He configurado esto:

 let element = document.createElement('a'); element.setAttribute('href', 'data:text/json;charset=utf-8,'+encodeURIComponent(JSON.stringify(response.data.json))); element.setAttribute('download', `myFile.json`); element.style.display = 'none'; document.body.appendChild(element); element.click(); document.body.removeChild(element);

Cuando la función se dispara, no pasa nada. Lo extraño es que si vuelvo a crear manualmente el URI (escribiendo data:text/json y la cadena encodeURIComponent en la URL), se muestra correctamente en la nueva pestaña.

¿Sería una cadena demasiado larga la fuente del problema? ¿Es algo completamente diferente?

Gracias

about 4 years ago · Santiago Trujillo
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!