Browse Source

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

master
kj1352 10 months ago
parent
commit
c2ea010b00
1 changed files with 12 additions and 24 deletions
  1. +12
    -24
      main.js

+ 12
- 24
main.js View File

@@ -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() {


Loading…
Cancel
Save