Skip to content

Instantly share code, notes, and snippets.

@liximomo
Created December 30, 2016 01:50
Show Gist options
  • Save liximomo/2816b368a5c52d61a4ec0e0ea05777ba to your computer and use it in GitHub Desktop.
Save liximomo/2816b368a5c52d61a4ec0e0ea05777ba to your computer and use it in GitHub Desktop.
function toDataURL(url) {
return fetch(url, {
credentials: 'include',
})
.then(response => response.blob())
.then(blob => new Promise((resolve, reject) => {
var reader = new FileReader();
reader.onloadend = () => resolve(reader.result);
reader.onerror = reject;
reader.readAsDataURL(blob);
}));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment