I have a flask server that sends a pdf file with the send_file function.
When I test this route on postman I can view and download the pdf.
However when I try to download it through my React frontend the file is blank BUT with the correct amount of pages.
I suppose the problem stems from my use of blob but I don’t see how.
Server route
@app.route("/test", methods=["GET"])
def results():
if request.method == "GET":
return send_file("pdf-path", cache_timeout=0, as_attachment=True)
This route works fine when tested on postman. I can view the pdf
client side
axios.get(URL + '/test')
.then(function (response) {
if (response.status === 200) {
const type = 'application/pdf';
const file = new Blob([data], { type: type });
saveAs(file, "test.pdf");
}
}
)
Here I am using axios and file-saver.
The file is downloaded but all the pages are empty.