-
-
Save jakearchibald/b7d63a48db6484e1b5701331ed8c7a02 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
function bufferFetch(url) { | |
return new Promise((resolve, reject) => { | |
const xhr = new XMLHttpRequest(); | |
xhr.responseType = 'arraybuffer'; | |
xhr.onload = () => resolve(xhr.response); | |
xhr.onerror = () => reject(Error('Fetch failed')); | |
xhr.open('GET', url); | |
xhr.send(); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment