Created
December 30, 2016 01:50
-
-
Save liximomo/2816b368a5c52d61a4ec0e0ea05777ba to your computer and use it in GitHub Desktop.
This file contains hidden or 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 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