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.