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

268
Visualizações
React and Node app download zip file from REST API

I have a React and Node app and I have a table with download button. When I click the download button it makes a request to the node app which I want it to make a call to a REST API to download a zip file in the browser.

I managed to download the zip file by linking the REST API url directly from React but my manager told me not to expose the API url and mask it through Node.

I tried different methods that I found on the web but none of them work, just one that downloaded a zip that contained a file that contained base64 of the files probably.

I would like a solution both for React and Node how to download from a REST API.

Thanks

React code:

 $("#example tbody").on('click', '#buton123', function() {
   
   
  var 
   id=response.data.mesaje[$(this).closest('tr').index()].id;
 
   article2 = {id2:id} 
   axios.post('http://localhost:3001/descarcare',article2)
   .then((respo 
    nse)=>{
   //How to download zip from node 
   })

   });

Node code:

app.post('/descarcare', function(req, res) {

var id = req.body.id2;
console.log(id);


axios.get('http://restapi.com/aaa?id=123').then((response)=>{
//Code to download zip from rest api
)}




});
about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

You can do one thing make api request to your source zip file containing rest api from nodejs and get stream data and then pipe it res. In this way you can get stream data directly to react js application from nodejs application

about 4 years ago · Juan Pablo Isaza Relatório

0

Check jszip and jszip-utils libraries available for zipping the content.

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