Created
July 24, 2019 09:16
-
-
Save gusmantap/ee2b295d59e999f0c7c1d0f81a62b2d2 to your computer and use it in GitHub Desktop.
Axios loading data with percentage
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
let config = { | |
onUploadProgress: progressEvent => { | |
let percentCompleted = Math.floor((progressEvent.loaded * 100) / progressEvent.total); | |
// do whatever you like with the percentage complete | |
// maybe dispatch an action that will update a progress bar or something | |
} | |
} | |
axios.post('/path/to/post/', data, config) | |
.then(response => console.log(response)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment