Skip to content

Instantly share code, notes, and snippets.

@chongiscool
Created April 24, 2018 14:43
Show Gist options
  • Save chongiscool/6751362919c2fe683814d94c8acc40b8 to your computer and use it in GitHub Desktop.
Save chongiscool/6751362919c2fe683814d94c8acc40b8 to your computer and use it in GitHub Desktop.
JS 'get' templete from codecademy
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