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:
Jonas Jenwald 2024-03-01 10:23:02 +01:00 committed by GitHub
commit 61036383b5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -435,21 +435,15 @@ async function fetchData(url, type = "text") {
return;
}
if (request.status === 200 || request.status === 0) {
let data;
switch (type) {
case "arraybuffer":
case "blob":
case "json":
data = request.response;
break;
default:
data = request.responseText;
break;
}
if (data) {
resolve(data);
resolve(request.response);
return;
}
resolve(request.responseText);
return;
}
reject(new Error(request.statusText));
};