-
-
Notifications
You must be signed in to change notification settings - Fork 11k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
request progress? #629
Comments
I figured it out. So I can also use the |
@four-eyes-04-04 How did you use the method to Show the progress, an example please! |
@slim12kg
Depending on the way you coded your project it may change, if my code confuses you, please don't hesitate to ask me more and I will gladly help as soon as I read your response. You're welcome. :-) |
@four-eyes-04-04 Thanks for the help! |
Any way to determine the download progress of a request? |
@PierBover Use onDownloadProgress instead of onUploadProgress. Found it in the Request Config section here https://github.com/mzabriskie/axios. Hope this helps! UPDATE: Found this issue #928 |
How can I track the complete progress from 0 - 100%? I always got 0 or Nan and 100 |
Hi all! Is it possible to use onDownloadProgress with the axios.all function? |
@jcmidia download is handled by the browser, right? |
Hey guys, you can use the intercetor if you want to handle this in a global form. Like so: import Axios from 'axios';
function onUploadProgress (ev) {
console.log(ev);
// do your thing here
}
function handleUploadProgress (ev) {
console.log(ev);
// do your thing here
}
Axios.interceptors.request.use(config => {
...config,
onUploadProgress,
onDownloadProgress
}); Add those codes on your entry file, then on your other files (views or components): aFile.js import Axios from 'axios';
function makeRequest () {
axios.get('/to/path')
.then(({ data })=> {
console.log(data);
});
} anotherFile.js import Axios from 'axios';
function makeRequest () {
axios.post('/to/path', data, yourConfigIfAny)
.then(({ data }) => {
console.log(data);
});
}
There's a trade off to this. If you sent multiple requests it would be up to you to maybe sum their You can modify the code above a little bit to be more flexible like so: import Axios from 'axios';
function onUploadProgress (ev) {
console.log(ev);
// do your thing here
}
function handleUploadProgress (ev) {
console.log(ev);
// do your thing here
}
Axios.interceptors.request.use(config => {
...config,
onUploadProgress: config.onUploadProgress || onUploadProgress,
onDownloadProgress: config.onDownloadProgress || onDownloadProgress
}); Now you can provide a custom import Axios from 'axios';
function customOnUploadProgress (ev) {
console.log('customOnUploadProgress', ev);
}
function makeRequest () {
axios.post('/to/path', data, {
onUploadProgress: customOnUploadProgress
})
.then(({ data }) => {
console.log(data);
});
} |
Hi guys. I followed what you told us, but sadly, just like @jayzyaj , I'm always getting "100" as a result, both on upload/download. Do you know where that could come from? My code is very similar to @aprilmintacpineda , an interceptor, and then I just copied/pasted the 2 functions. |
Only 100% can be fired in case your upload files are too small, or download/upload speed is too fast. Try to upload 10mb file maybe.
configuring axios requests with object was an issue, as |
Hi, how to use this code ? |
Hi, I need to show the download progress.... I have my logic written in JSP file... ho do I write it in react? PFB the code:
|
I have seen the issue at #82 if for example I have these codes
Is there any way to find out the current progress of the request? I need it for a customized loading bar. It would be great if I could get it on percentage or if not I could simply get a value that I can use to find out how much progress has pass.
The text was updated successfully, but these errors were encountered: