0

I am writing a gnome shell extension in java script. I tried using asynchronous fetch() but it didn't work.

How can I fetch data from a server in JSON format and display it on my status bar?

 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()
matthias_h
  • 11,356
  • 9
  • 22
  • 40
  • Welcome to Stack Exchange. This question is quite broad and would require quite a bit of time to answer. Please see [help]. – Mark Stewart Mar 23 '20 at 17:08

1 Answers1

0

I don't believe XMLHttpRequest is part of GJs:

You can use libsoup from imports.gi.

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

HTMLFiver
  • 11
  • 4