From 59e1ea966bb0c173eac689dd3a72a5e4d5b254e0 Mon Sep 17 00:00:00 2001 From: Adil Sadqi <42699429+AdilSadqi@users.noreply.github.com> Date: Sat, 6 Apr 2024 23:33:18 +0000 Subject: [PATCH] Update main.js.download --- index_files/main.js.download | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/index_files/main.js.download b/index_files/main.js.download index 25e606f..f4b91a9 100644 --- a/index_files/main.js.download +++ b/index_files/main.js.download @@ -202,14 +202,19 @@ function commander(cmd) { function performSpeedTest(callback) { // Using a free service to perform speed test fetch('https://www.speedtest.net/api/js/speedtest-cdn-mini.php') - .then(response => response.json()) + .then(response => { + if (!response.ok) { + throw new Error('Network response was not ok'); + } + return response.json(); + }) .then(data => { // Extracting download and upload speeds from the response const downloadSpeed = data.download; const uploadSpeed = data.upload; callback({ download: downloadSpeed, upload: uploadSpeed }); }) - .catch(error => callback({ error: "Unable to perform speed test" })); + .catch(error => callback({ error: "Unable to perform speed test. " + error.message })); } // Displaying the download and upload speeds @@ -222,7 +227,6 @@ function commander(cmd) { } }); break; - case "update": addLine("Opening Updater...", "color2", 80); setTimeout(function() {