Create a base64 image from a fetch image

I would like to fetch an image and generate a base64 from it

this is what I have:

const res = await fetch('https://cdn.cnn.com/cnnnext/dam/assets/211010073527-tyson-fury-exlarge-169.jpg')
  const blob = await res.blob();
  
  console.log(blob)
  console.log(btoa(blob))

everywhere on google they say to use FileReader, but it doesn’t exist in the service workers.

Any idea how to resolve it?

thanks!

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.