Skip to content

Instantly share code, notes, and snippets.

@deadlysyn
Last active February 22, 2018 16:36
Show Gist options
  • Save deadlysyn/2a81977ab85e1765018a926ec22950e3 to your computer and use it in GitHub Desktop.
Save deadlysyn/2a81977ab85e1765018a926ec22950e3 to your computer and use it in GitHub Desktop.
// XHR
const btnXHR = document.querySelector('#btnXHR')
btnXHR.addEventListener('click', function() {
let XHR = new XMLHttpRequest()
XHR.onreadystatechange = function() {
if (XHR.readyState == 4 && XHR.status == 200) {
PRICE.textContent = JSON.parse(XHR.responseText).bpi.USD.rate + ' USD'
}
}
XHR.open('GET', API)
XHR.send()
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment