Skip to content

Instantly share code, notes, and snippets.

@jakearchibald
Created November 25, 2016 13:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jakearchibald/b7d63a48db6484e1b5701331ed8c7a02 to your computer and use it in GitHub Desktop.
Save jakearchibald/b7d63a48db6484e1b5701331ed8c7a02 to your computer and use it in GitHub Desktop.
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