浏览代码

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

master
kj1352 1年前
父节点
当前提交
c2ea010b00
共有 1 个文件被更改,包括 12 次插入24 次删除
  1. +12
    -24
      main.js

+ 12
- 24
main.js 查看文件

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


正在加载...
取消
保存