Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
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 = () => {
// .then(convertBlobToBase64)
// .then(console.log)
Copy link

surajsharma commented Oct 1, 2020

this has been invaluable, thanks :)

Copy link

lapc18 commented Aug 5, 2021

thank you so much, this snippet will save the night!

Copy link

vishu3278 commented Oct 5, 2021

Thanks for the solution.

Copy link

pavelglebov commented Feb 13, 2022

Awesome! Thank you!

Copy link

criticalmiind commented Jul 10, 2022

export const fetchAsBlob = url => fetch(url).then(response => response.blob()); 
not working in React Native android and Nodejs, working for iOS!
any alternative solution

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment