Skip to content

Instantly share code, notes, and snippets.

@YasuakiHirano
Last active February 17, 2020 02:59
Show Gist options
  • Save YasuakiHirano/d9b4543eb3caf4eccf4f5a7aa064b302 to your computer and use it in GitHub Desktop.
Save YasuakiHirano/d9b4543eb3caf4eccf4f5a7aa064b302 to your computer and use it in GitHub Desktop.
open files pdf with ajax(axios)
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