I\'m trying to use the Image API to get the image data/extension for image urls.
I can easily use regex to the file extension from names like {domain}.com/path-to-im
You can use fetch()
, Response.blob()
, FileReader.prototype.readAsDataURL()
fetch("http://placekitten.com/g/1000/1000")
.then(response => response.blob())
.then(blob => {
console.log(blob.type);
let reader = new FileReader();
reader.onload = () => {
console.log(reader.result)
}
reader.readAsDataURL(blob)
})