I'm using XMLHttpRequest to upload .psd files in my application & listening to events with addEventListener.
Code sample:
const request = new XMLHttpRequest();
request.open('POST', url);
request.upload.addEventListener('progress', ({ lengthComputable, loaded, total }) => {
if (lengthComputable) {
const feedData = { loaded, total };
// do something with the data
}
});
How can I use fetch in place of XMLHttpRequest & access the lengthComputable, loaded & total?
Because I want to show a loading bar indicating the uploading progress with that data.