Skip to content

Instantly share code, notes, and snippets.

@gusmantap
Created July 24, 2019 09:16
Show Gist options
  • Save gusmantap/ee2b295d59e999f0c7c1d0f81a62b2d2 to your computer and use it in GitHub Desktop.
Save gusmantap/ee2b295d59e999f0c7c1d0f81a62b2d2 to your computer and use it in GitHub Desktop.
Axios loading data with percentage
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