Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View joaolucasgtr's full-sized avatar
💭
🎸 🎵

João Lucas joaolucasgtr

💭
🎸 🎵
View GitHub Profile
@joaolucasgtr
joaolucasgtr / cloudSettings
Last active March 16, 2021 11:44
Visual Studio Code Settings Sync Gist
{"lastUpload":"2021-03-16T11:44:34.045Z","extensionVersion":"v3.4.3"}
@joaolucasgtr
joaolucasgtr / xhr-file-download.js
Last active July 10, 2020 00:42
Automatically "download" a pdf you retrieved from api.
let url = 'https://<your pdf endpoint>';
let filename = 'File.pdf';
let xhr = new XMLHttpRequest();
xhr.responseType = 'blob'; // set response type to blob
xhr.onreadystatechange = () => {
if (xhr.readyState == 4 && xhr.status == 200) {
// create a blob with the content in XHR's response:
let blob = new Blob([xhr.response], { type: 'application/pdf' });