question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

listen to upload progress event, every 10% onUploadProgress

See original GitHub issue

Describe the question How can I set a interval count to onUploadProgress

Example Code

 axios.request( {
                 method: "post",
                 url: URL",
                 data: data,
                 responseType:'json',
                 onUploadProgress: (p) => {
                     this.setState({
                         progress: p.loaded  / p.total
                     })
                 }

Expected behavior, if applicable Should listen to download progress event, every 10%

Environment:

  • Axios Version [^0.18.0]
  • Additional Library Versions [e.g. React 16.8.3, React Native 0.59.5]

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
ComputerCarlcommented, Jun 15, 2019

Listen to all the events but only respond to them using modulus Math.floor(written/total) % 10 === 0. Since this may happen many times, also use a flag to check if event was emitted already?

1reaction
jasonsaaymancommented, Jun 6, 2019

@liamm12 I had a look at the source and there is currently no native way of doing what you would like to within axios however I’m certain that you could intercept the native progress event and then handle that via an interval.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Implementing a file upload status progressbar with Axios ...
In the above code snippet, we are calling the onUploadProgress event with progressEvent as a parameter, which will in turn capture the loaded ......
Read more >
how to get onUploadProgress in axios? - Stack Overflow
To see multiple upload progress events in development, create a custom Network Throttling Profile simulating uploading at 50KB/s: Custom > Add..
Read more >
Axios upload progress with progress bar tutorial - YouTube
Source code: https://openjavascript.info/2022/06/06/ upload - progress -bar-with-axios/⚡ Looking for high-performance, affordable web hosting ...
Read more >
Next.js file upload progress bar using Axios - Codersteps
In this article, you will learn how to get the upload progress ... api doesn't support listening to events that can help us...
Read more >
Angular 10/9 File Upload Tutorial: Listen for HTTP Events ...
Angular 10/9 File Upload Tutorial: Listen for HTTP Events & Progress Bar Example. Angular Upload. In this tutorial, we'll learn how to ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found