use XMLHttpRequest, i listener 'progress', as below:
var XHR = new XMLHttpRequest();
XHR.upload.addEventListener("progress", function(e) {
if (e.lengthComputable) {      
var percentComplete = Math.round(e.position * 100 / e.total);
console.log(percentComplete);
}
}, false);
How do this with fetch ?
Monitoring progress is not a feature of the Fetch API. Using XMLHttpRequest is the best way for now.
Bonus tip! You can use the triple back tick ``` to format code blocks in comment fields:
https://guides.github.com/features/mastering-markdown/#GitHub-flavored-markdown
This should do the trick: https://gist.github.com/domenic/95e689d0be5e24fb08ec
Did it plan to include it in the final specs?
It is already included in the spec, in a different form; please see the above linked gist for how you can translate from the new form to the old form.
ok, thanks you!
ok. i got it. thanks much.
@domenic I don't understand how to use that snippet to monitor upload progress - in the spec I can only see streams for the response object, not the request object…
Most helpful comment
@domenic I don't understand how to use that snippet to monitor upload progress - in the spec I can only see streams for the response object, not the request object…