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

307
Visualizações
Download a file using node server when clicked on a button - react.js

I have a excel file (sample.xlsx) in the root of my app folder. I want to download the file using node server only. In the node server I download the the file using res.download() https://www.geeksforgeeks.org/express-js-res-download-function/

When I directly hit the url http://localhost:8080/downloadFile , it perfectly saves/downloads the excel sheet. But now, I want to create a button and then hit this url. Hence, I access the url by making a proxy api call in order to use res.download() in server file, but res.download does not seem to directly download the file. Instead it sends a response. But that response is in some other format..with special characters... like this: ��k�����f��[%3�Eq���RUB .. How do I convert or read this response data? (This response data is the content of the file I am trying to download ) ... My next idea was to take the response and convert it into a blob.. and then save/download as an excel file.

I am really stuck on this for a very long time. Any help is appreciated.

Note: I would like to download this file via node server only. .. I do not want to use the public folder to host the file on the front end server not do I want to use <a href = "" > technique.

about 4 years ago · Juan Pablo Isaza
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