Reputation: 53
What are the disadvantages in using onUploadProgress
and onDownloadProgress
in axios for json data? Because I have mostly seen people use it for file upload..
Does it only serve for file down or upload purposes? What other use cases do onUploadProgress
an onDownloadProgress
have?
Upvotes: 2
Views: 503
Reputation: 762
What are the disadvantages in using onUploadProgress and onDownloadProgress in axios for json data?
If you have the right use case and you want to show the user how fast or slow the json uploads/downloads there is absolutely no disadvantage, most of times you would use json to build your dom though, so there are more appropriate ways to check if the dom has been built or not.
Does it only serve for file down or upload purposes?
I would say 99% of the time. As the documentation states:
One difference that may end up being a show-stopper for some is progress updates on uploads/downloads. As Axios is built on top of the older XHR API, you’re able to register callback functions for onUploadProgress and onDownloadProgress to display the percentage complete in your app’s UI. Currently, Fetch has no support for doing this.
What other use cases do onUploadProgress an onDownloadProgress have?
You could also start a upload/download to check connection speeds between the user and your server. Even though this is probably not the best way either.
Does onUploadProgress create a delay from frontend dealing with json data
The documentation doesn't imply it would cause any delays.
Upvotes: 1