diff --git a/src/platform/web/dom/request/xhr.js b/src/platform/web/dom/request/xhr.js index 98893387..c3ad8ae8 100644 --- a/src/platform/web/dom/request/xhr.js +++ b/src/platform/web/dom/request/xhr.js @@ -37,6 +37,11 @@ class RequestResult { function createXhr(url, {method, headers, timeout, format, uploadProgress}) { const xhr = new XMLHttpRequest(); + + if (uploadProgress) { + xhr.upload.addEventListener("progress", evt => uploadProgress(evt.loaded)); + } + xhr.open(method, url); if (format === "buffer") { @@ -56,10 +61,6 @@ function createXhr(url, {method, headers, timeout, format, uploadProgress}) { xhr.timeout = timeout; } - if (uploadProgress) { - xhr.upload.addEventListener("progress", evt => uploadProgress(evt.loaded)); - } - return xhr; }