Last active
October 10, 2024 15:11
-
-
Save virolea/e1af9359fe071f24de3da3500ff0f429 to your computer and use it in GitHub Desktop.
Tracking file upload progress using axios
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
upload(files) { | |
const config = { | |
onUploadProgress: function(progressEvent) { | |
var percentCompleted = Math.round((progressEvent.loaded * 100) / progressEvent.total) | |
console.log(percentCompleted) | |
} | |
} | |
let data = new FormData() | |
data.append('file', files[0]) | |
axios.put('/endpoint/url', data, config) | |
.then(res => console.log(res)) | |
.catch(err => console.log(err)) | |
} |
Really helpful, thanks
Nice. thanks!
Thank you bro
Hi, but this is giving me 401 unauthorized error when i call my API, Why is that?
Thank :)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
you lou bro :)