Created
July 6, 2020 11:25
-
-
Save kennethteh90/932d29a7c1fce5bcf3888a141bb3e954 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
requestPdf() { | |
axios.request({ | |
url: someUrl, | |
method: 'POST', | |
responseType: 'blob', | |
params: { | |
someParam: someParam | |
} | |
}) | |
.then(response => response.data) | |
.then(blob => { | |
const data = URL.createObjectURL(blob) | |
var link = document.createElement('a') | |
link.href = data | |
link.target = '_blank' | |
link.click() | |
window.URL.revokeObjectURL(blob) | |
}) | |
.catch((error) => { | |
console.log(error) | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment