Reputation: 2252
In order to measure progress, I'm thinking about doing these two things while making axios call:
So far I just have this where I can get the data but I need some way to get the metadata behind it (the information in the network console like file size, amount downloaded so far)
const request = axios.get('/data');
request.then((response) => {
}
Or is there another way of measuring progress?
Upvotes: 2
Views: 2669
Reputation: 1964
you just need to pass in a configuration object with the onUploadProgress function:
let progress = 0;
const request = axios.post('/data', {
onUploadProgress: function(event) {
progress = Math.round((event.loaded * 100) / event.total);
}
});
request.then((response) => {
//
}
then use the progress variable as you wish.
Note: If using a get
request use onDownloadProgress
as mentioned here
Upvotes: 5