Created
February 9, 2021 09:15
-
-
Save sabesansathananthan/55411cfcd50c290e696230045a6784f4 to your computer and use it in GitHub Desktop.
Axios Vs Fetch
This file contains hidden or 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
loadProgressBar(); | |
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) | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment