Procházet zdrojové kódy

Fix: Made all process non-async to avoid the function from not waiting for the HTTP request to finish

master
kj1352 před 1 rokem
rodič
revize
c2ea010b00
1 změnil soubory, kde provedl 12 přidání a 24 odebrání
  1. +12
    -24
      main.js

+ 12
- 24
main.js Zobrazit soubor

@@ -59,30 +59,18 @@ function createMainWindow() {
});
}

async function sendAPIRequest(data = {}) {
try {
const response = await fetch(endpoint, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(data),
});

const textResponse = await response.text();
try {
const result = JSON.parse(textResponse.toString());
if (!response.ok) {
console.error(`API call failed with is_online: ${response.is_online}`, result);
} else {
console.log('API call succeeded:', result.toString());
}
} catch (jsonError) {
console.error('Error parsing JSON response:', textResponse.toString());
}
} catch (error) {
console.error('Error during API call:', error.toString());
}
function sendAPIRequest(data = {}) {
fetch(endpoint, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(data),
}).then(function (response) {
console.log("Pass: ", response);
}, function (error) {
console.log("Error: ", error)
});
}

function getMacAddress() {


Načítá se…
Zrušit
Uložit