I'm trying to track the progress of data upload on my react native app. I use the plugin apiSauce to call my server running locally (node server with baseURL : 192.xxx.x.xx":9000/).
On the front part I called my api using 'apisauce' with the code below :
const apiClient = create({
baseURL: "http://192.xxx.x.xxx:9000/api",
});
return apiClient.post(endpoint, myData, {
onUploadProgress: (progress) => {
console.log(progress.loaded / progress.total);
},
});
From that I except several logs in my console like : 0.1 , 0.2,0.3, ... , 0.9, 1.0 but what I got now is only one log : 1.
I dont understand why onUploadProgress is only fired once, I tried to throttle the network on the android virtual device that I'm using for my test, also running the server with baseURL : 127.0.0.1 doesn't seem to fix my issue.
I had the same problem and the code was just fine (similar to the one you posted LePetitPrince), the problem was the speed when doing this locally (it instantly uploaded and therefore only 1 progress report was made).
To actually see the progress on the console I went and searched for a 10MB image file (this one should work: https://commons.wikimedia.org/wiki/File:Pizigani_1367_Chart_10MB.jpg) and changed the network to Slow 3G on DevTools and then I got to see the several calls with progress being made.
You can refer to this github issue for more details.