从gnome扩展名的服务器获取json文件

问题描述 投票:0回答:1

我正在用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()
javascript xmlhttprequest gnome gnome-shell-extensions
1个回答
0
投票

我不相信XMLHttpRequest是GJ的一部分:

您可以从imports.gi使用libsoup。

https://developer.gnome.org/libsoup/stable/

© www.soinside.com 2019 - 2024. All rights reserved.