Last active
February 17, 2020 02:59
-
-
Save YasuakiHirano/d9b4543eb3caf4eccf4f5a7aa064b302 to your computer and use it in GitHub Desktop.
open files pdf with ajax(axios)
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
axios({ | |
url: 'http://localhost/static/example.pdf', | |
method: 'GET', | |
responseType: 'blob', | |
}).then((response) => { | |
const file = new Blob([response.data], { type: 'application/pdf' }); | |
const fileURL = URL.createObjectURL(file); | |
window.open(fileURL, '_target') | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment