Skip to content

Instantly share code, notes, and snippets.

@kennethteh90
Created July 6, 2020 11:25
Show Gist options
  • Save kennethteh90/932d29a7c1fce5bcf3888a141bb3e954 to your computer and use it in GitHub Desktop.
Save kennethteh90/932d29a7c1fce5bcf3888a141bb3e954 to your computer and use it in GitHub Desktop.
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