我正在尝试编写执行以下操作的chrome扩展程序:
下面是我的代码,我觉得我很近,但是找不到错误:
var leslie_status = "";
var t = 0;
var intervalID = window.setInterval(getLeslie, 1800) //start getLeslie
function getLeslie(){
fetch("https://api.torn.com/user/15?selections=&key=munQc9gdElHPf49I")
.then(function(resp) {
return resp.json();
})
.then(function(data) {
var leslie_status = data.status[0];
console.log("L: ",leslie_status);
})
.then(function(leslie_status) {
if (leslie_status == "Okay"){
var t = setTimout(leslieAlert, 10);
}
else{
console.log("Leslie is in hospital.")
}
});//end data
}
function leslieAlert(){
alert("Time to kill leslie");
}
当前仅输出'“ L:”,leslie_status'
我仍在学习JS,因此这里的任何帮助将不胜感激
欢呼