The progess of the file upload is not being console logged. Why?
Here is the code I have:
const xhr = new XMLHttpRequest();
xhr.open('POST', apiUrl);
xhr.upload.addEventListener("progress", function(e){
console.log(e.loaded/e.total)
})
xhr.onload = () => {
const response = JSON.parse(xhr.response);
console.log(response);
// ... do something with the successful response
};
xhr.send(formData);
Your
apiUrlresponse must have the HTTP response headerContent-Length. If it doesn't, there is nothing to compute.Maybe the event handler should be bound to
xhr: