From 33c5ef349e6decab66e189080ddf6b3c071960bc Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Wed, 21 Feb 2024 22:58:44 +0100 Subject: [PATCH] Simplify the `XMLHttpRequest`-branch in the `fetchData` helper function (PR 17277 follow-up) --- src/display/display_utils.js | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/src/display/display_utils.js b/src/display/display_utils.js index e7e52c6c1..98c8e4714 100644 --- a/src/display/display_utils.js +++ b/src/display/display_utils.js @@ -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); - return; + resolve(request.response); + return; } + resolve(request.responseText); + return; } reject(new Error(request.statusText)); };