This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //boilerplate code for an AJAX GET request using an XMLHttpRequest object | |
| const xhr = new XMLHttpRequest(); | |
| const url = 'https://api-to-call.com/endpoint'; | |
| //xhr - XMLHttpRequest, it is a common practice to name this object | |
| xhr.responseType = 'json'; | |
| xhr.onreadystatechange = () => { | |
| //The purpose of this conditional statement checks to see if the request has finished. | |
| if (xhr.readyState === XMLHttpRequest.DONE) { |
NewerOlder