Created
July 2, 2022 16:46
-
-
Save andrepgsilva/8d6dd8409a82034c166da1a2beb4c42b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async function downloadImage(imageSrc) { | |
const image = await fetch(imageSrc) | |
const imageBlog = await image.blob() | |
const imageURL = URL.createObjectURL(imageBlog) | |
const link = document.createElement('a') | |
link.href = imageURL | |
link.download = 'image file name here' | |
document.body.appendChild(link) | |
link.click() | |
document.body.removeChild(link) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment