Created
October 26, 2020 20:55
-
-
Save allangrds/0b303df5a122ef44d21372a955a01385 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
<img id="img"> | |
<script> | |
loadProgressBar(); | |
const url = 'https://fetch-progress.anthum.com/30kbps/images/sunrise-baseline.jpg'; | |
function downloadFile(url) { | |
axios.get(url, {responseType: 'blob'}) | |
.then(response => { | |
const reader = new window.FileReader(); | |
reader.readAsDataURL(response.data); | |
reader.onload = () => { | |
document.getElementById('img').setAttribute('src', reader.result); | |
} | |
}) | |
.catch(error => { | |
console.log(error) | |
}); | |
} | |
downloadFile(url); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment