Skip to content
← Back to Community
Javascript GET JSON data from API
Profile icon
g7kse

I think I've got myself in a muddle with something I thought would be fairly simple. I am trying to return the name and status of a ground station from and API. I want to display this in a browser. The Repl is here https://repl.it/@g7kse/SatNOGS-Javascript.

I could do with a pointer. I followed a few tutorials and its not really doing what it ought to. You will see that coding is not my chosen specialist skill ;-)

I have a feeling it has to the with the data being in [0] and [antenna]. Is that correct?

Voters
Profile icon
g7kse
Comments
hotnewtop
Profile icon
[deleted]

Here is the proper way to do it using the well supported and modern ** fetch ** function: https://repl.it/@freddiethefrog/SatNOGS-Javascript

Profile icon
g7kse

Ta @freddiethefrog & @MrEconomical
Couldn't have done that in a week without the pointers. Brilliant. Thanks

5 points each surely!

Profile icon
[deleted]

@g7kse: Cool!

Profile icon
MrEconomical

for XMLHttprequests, use req.onload to get when the request is done and use req.responseText or req.response to get the result

example:

let req = new XMLHttpRequest() req.open("GET", url) req.send() req.onload = function() { console.log(req.responseText) }
Profile icon
g7kse

Thanks @MrEconomical. That was very quick!

Profile icon
Vandesm14

@g7kse if @MrEconomical answered your question, be sure to mark his comment as the answer!

Profile icon
MunnaKabir

nks for sharing the article, and more importantly, your personal experience mindfully using our emotions as data about our inner state and knowing when it’s better to de-escalate by taking a time out are great tools. App https://shareit.onl/ reciate you reading and sharing your story since I can certainly relate and I think others can to