0

I'm trying to fetch and convert into blob/base64 an image from an online resource but the code I'm using seems not working

fetch('https://example.com/image.jpg')
.then( res => res.blob() )
.then( data => {
    const reader = new FileReader()
    reader.onloaded = () => {
      console.log(reader.readAsDataURL(data))    
    }     
})

what's wrong with it and what I need to change to fix it?

fed3vt
  • 279
  • 1
  • 4
  • 16
  • Does this answer your question? [Convert blob to base64](https://stackoverflow.com/questions/18650168/convert-blob-to-base64) – Delwyn Pinto Sep 26 '20 at 10:51

1 Answers1

1

See Convert blob to base64

This issue was solved already ;)

nafts
  • 44
  • 5