How get progress percentage in sending request? axios

Viewed 282

I'm currently creating React app now in which it should have progress percentage while sending the request.

I don't understand, it always logs directly one message which is 100% in my console even the request has not-yet-completed/pending.

Code in my axios:

onUploadProgress: (progressEvent) => {
    const { loaded, total } = progressEvent;
    let percent = Math.floor((loaded * 100) / total);
    console.log(`percentage => ${percentage}`);
},

In my console: enter image description here

I expect to have like these output like in this youtube-tutorial

enter image description here

0 Answers
Related