Skip to content

Instantly share code, notes, and snippets.

View lapc18's full-sized avatar
🎯
Focusing

Luis Adolfo Pimentel lapc18

🎯
Focusing
View GitHub Profile
@n1ru4l
n1ru4l / index.js
Created August 7, 2017 10:47
Fetch blob and convert to base64
export const fetchAsBlob = url => fetch(url)
.then(response => response.blob());
export const convertBlobToBase64 = blob => new Promise((resolve, reject) => {
const reader = new FileReader;
reader.onerror = reject;
reader.onload = () => {
resolve(reader.result);
};
reader.readAsDataURL(blob);