Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2019
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.42 KB | None | 0 0
  1. axios(`${apiURL}/pdf`, {
  2. method: 'GET',
  3. responseType: 'blob' //Force to receive data in a Blob Format
  4. })
  5. .then(response => {
  6. //Create a Blob from the PDF Stream
  7. const file = new Blob(
  8. [response.data],
  9. {type: 'application/pdf'});
  10. //Build a URL from the file
  11. const fileURL = URL.createObjectURL(file);
  12. //Open the URL on new Window
  13. window.open(fileURL);
  14. })
  15. .catch(error => {
  16. console.log(error);
  17. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement