Answer the question
In order to leave comments, you need to log in
How to rewrite the code so that it can be used in a loop?
var onLinedsasd=(async()=>{
if(navigator.onLine){
var date=+new Date();
var res=await fetch('/favicon.ico?_='+date);
var ret=await res.headers.get('Content-Type').split('/')[0]=='image';
}else{
ret=navigator.onLine;
}
return ret;
});
if(onLinedsasd()){
//...
}else{
//...
}
Answer the question
In order to leave comments, you need to log in
Because await is only valid inside async functions and in the global scope of a module (c) google translate
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question