Created
November 25, 2017 17:51
-
-
Save brettvaida/46b1ff3a08f068306f4854ca55b695f0 to your computer and use it in GitHub Desktop.
AJAX GET request boilerplate
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
const xhr = new XMLHttpRequest(); | |
const url = 'https://api-to-call.com/endpoint'; | |
xhr.responseType = 'json'; | |
xhr.onreadystatechange = function() { | |
if (xhr.readyState === XMLHttpRequest.DONE) { | |
console.log(xhr.response); | |
} | |
}; | |
xhr.open('GET', url); | |
xhr.send(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment