mieqq
刚刚有尝试过编写脚本,但是在无法解析的情况下端点返回json为0,此时脚本已经超时。可能是我JavaScript技术不精,请多指点
const http_api = "https://localhost:6171";
const http_api_key = "some_key";
const headers = {
'Content-Type': 'application/json',
'X-Key': `${http_api_key}`
};
fetch(`${http_api}/v1/test/dns_delay`, {
method: 'POST',
headers: headers
})
.then(response => {
console.log(response);
return response.json();
})
.then(data => {
if (data.delay = 0) {
fetch(`${http_api}/v1/dns/flush`, {
method: 'POST',
headers: headers
});
$done();
}
console.log("No need to flush DNS")
$done();
})
.catch((error) => {
console.error('Error:', error);
$done();
});