Skip to content

Instantly share code, notes, and snippets.

@melloc01
Last active August 29, 2015 14:23
Show Gist options
  • Save melloc01/1f2b42aff2e73d7f2f17 to your computer and use it in GitHub Desktop.
Save melloc01/1f2b42aff2e73d7f2f17 to your computer and use it in GitHub Desktop.
Como fazer uma requisição à uma API com Javascript puro
function XhrRequestExample {
var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange=function() {
if (xmlhttp.readyState==4 && xmlhttp.status==200){
//handle success
}
}
xmlhttp.open("GET",'http://url-that-you-want/to-fetch');
xmlhttp.send();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment