Published
- 1 min read
get image base64 javascript
The solution for this is noted below
get image base64 javascript
Solution
const getBase64FromUrl = async (url) => {
const data = await fetch(url)
const blob = await data.blob()
return new Promise((resolve) => {
const reader = new FileReader()
reader.readAsDataURL(blob)
reader.onloadend = () => {
const base64data = reader.result
resolve(base64data)
}
})
}
getBase64FromUrl('your_image_url_here').then(console.log)
Try other methods by searching on the site. That is if this doesn’t work