Created
June 11, 2018 16:54
-
-
Save clairtonluz/a16346341162c5272294cb6ed55c4b8e to your computer and use it in GitHub Desktop.
This file contains 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
// faz uma requisiço do tipo post e o response dessa requisição é o PDF | |
this.fetch(`blog.clairtonluz.com.br/gerarPDF`, {method: 'POST'}) | |
.then(response => response.blob()) | |
.then(file => { | |
// Criar uma url local para o arquivo baixado. | |
const url = window.URL.createObjectURL(blob); | |
// Criar um link | |
const a = document.createElement('a'); | |
// define o href do link para a url criada | |
a.href = url; | |
// define o nome para o arquivo que vai ser baixado | |
a.download = 'nomeDoArquivo.pdf'; | |
// inicia o download no navegador | |
a.click(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment