forked from mystiq/hydrogen-web
Add event handler before executing open
Signed-off-by: RMidhunSuresh <hi@midhun.dev>
This commit is contained in:
parent
b011c3df03
commit
96a2dd7c72
1 changed files with 5 additions and 4 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue