0

(noob question), but I have some difficulties using the JSON data, I receive from the FAA NOTAM API and converting that via an id or class into html code.

(I have hidden the keys on purpose)

var xhr = new XMLHttpRequest();
xhr.addEventListener('load', function(e) {
  var response = e.target.responseText;
  console.log(response);
});
xhr.addEventListener('error', function(e) {
  console.error('Request error with status', e.target.status);
});
xhr.open('GET', 'https://external-api.faa.gov/notamapi/v1/notams?icaoLocation=ELLX');
xhr.setRequestHeader('client_id','');
xhr.setRequestHeader('client_secret','');
xhr.send();
<a id="input"></a>
Ted
  • 107
  • 5

1 Answers1

1

I don't recommend the old school way of asynchronous handling in js (XMLHTTPRequest) but in any way of handling asynchronous in js when you take response from api you should parse that json reponse to DOM. you can find your answer about steps of doing this in how-to-call-for-json-output-from-an-api-into-html.(linked post is using fetch api for handling asynchronous in js)

and also if you are new to asynchronous js, how-do-i-return-the-response-from-an-asynchronous-call this post have a good explanations of handling asynchronous js.

CyrusKabir
  • 133
  • 1
  • 8