我正在用Java脚本编写gnome shell扩展。我尝试使用异步fetch(),但是没有用。
我如何从服务器获取JSON格式的数据并将其显示在状态栏上?
const http = new XMLHttpRequest()
let data,button;
function load(){ >
http.open("GET", "https://example.com/")
http.send()
http.onload = (function(){
data = JSON.parse(http.responseText);
button.set_text(JSON.stringify(data));
})
}
load()