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}) {
|
function createXhr(url, {method, headers, timeout, format, uploadProgress}) {
|
||||||
const xhr = new XMLHttpRequest();
|
const xhr = new XMLHttpRequest();
|
||||||
|
|
||||||
|
if (uploadProgress) {
|
||||||
|
xhr.upload.addEventListener("progress", evt => uploadProgress(evt.loaded));
|
||||||
|
}
|
||||||
|
|
||||||
xhr.open(method, url);
|
xhr.open(method, url);
|
||||||
|
|
||||||
if (format === "buffer") {
|
if (format === "buffer") {
|
||||||
|
@ -56,10 +61,6 @@ function createXhr(url, {method, headers, timeout, format, uploadProgress}) {
|
||||||
xhr.timeout = timeout;
|
xhr.timeout = timeout;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (uploadProgress) {
|
|
||||||
xhr.upload.addEventListener("progress", evt => uploadProgress(evt.loaded));
|
|
||||||
}
|
|
||||||
|
|
||||||
return xhr;
|
return xhr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Reference in a new issue