Skip to content

Instantly share code, notes, and snippets.

@allangrds
Created October 26, 2020 20:55
Show Gist options
  • Save allangrds/0b303df5a122ef44d21372a955a01385 to your computer and use it in GitHub Desktop.
Save allangrds/0b303df5a122ef44d21372a955a01385 to your computer and use it in GitHub Desktop.
<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