Created
April 24, 2018 14:43
-
-
Save chongiscool/6751362919c2fe683814d94c8acc40b8 to your computer and use it in GitHub Desktop.
JS 'get' templete from codecademy
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.response); | |
console.log(xhr.response); | |
} | |
} | |
xhr.open('GET', url); | |
xhr.send(); // 'GET' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment