Merge pull request #17710 from Snuffleupagus/pr-17277-followup
Simplify the `XMLHttpRequest`-branch in the `fetchData` helper function (PR 17277 follow-up)
This commit is contained in:
commit
61036383b5
@ -435,21 +435,15 @@ async function fetchData(url, type = "text") {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (request.status === 200 || request.status === 0) {
|
if (request.status === 200 || request.status === 0) {
|
||||||
let data;
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case "arraybuffer":
|
case "arraybuffer":
|
||||||
case "blob":
|
case "blob":
|
||||||
case "json":
|
case "json":
|
||||||
data = request.response;
|
resolve(request.response);
|
||||||
break;
|
return;
|
||||||
default:
|
|
||||||
data = request.responseText;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (data) {
|
|
||||||
resolve(data);
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
resolve(request.responseText);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
reject(new Error(request.statusText));
|
reject(new Error(request.statusText));
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user