Download PDF Files in ReactJs

1

I have a small problem downloading files into PDF

I have an API that returns a array of bytes with type : "application/pdf" , if I call directly in the browser my route.

Ex: localhost/api/download/pdf/{id}

PDF download is seamlessly done

But in react , I'm using axios to perform the get request to my API and I'm using react-file-download to download the DATE of the response, but the PDF mounted is coming blank

I download to other formats, such as CSV and TXT, in the same way, using react-file-download and they are done without the slightest problem

But with PDF I'm having this problem

I saved the date that is coming in the axios reply this is the result: link

I'm currently "skirting" the problem using window.location.href to call my API's address. Ex: window.location.href = localhost / api / download / pdf / {id}

downloading is usually done

Has anyone ever been through this? how do you download PDF, or other files?

    
asked by anonymous 31.05.2017 / 20:57

1 answer

-2

Try to set the% s of% s so that it will work.

    
09.04.2018 / 15:40