Reputation: 299
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?
Upvotes: 0
Views: 437