From 96a2dd7c7299c2d9e2fecc8837167b413c870486 Mon Sep 17 00:00:00 2001 From: RMidhunSuresh Date: Thu, 4 Nov 2021 00:02:50 +0530 Subject: [PATCH] Add event handler before executing open Signed-off-by: RMidhunSuresh --- src/platform/web/dom/request/xhr.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) 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; }