我希望此函数返回true / false。但事实并非如此。它返回undefined。你能帮我吗?
function isAvailable() {
let startTime = new Date();
let isAvail = null;
Functions.getContentFromUrl(webLink + "/health-checker")
.then((html) => {
if (html.includes('Good!')) {
isAvail=true;
}
else {
console.error("Server is not available:" + html);
isAvail =false;
}
})
.catch((err) => {
console.error("this is error" + err);
isAvail =false;
}
)
return isAvail;
;
}