ソースを参照

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


読み込み中…
キャンセル
保存