Last active
November 24, 2017 18:53
-
-
Save maecapozzi/79fa4108af1223b12c51fca5af0548e2 to your computer and use it in GitHub Desktop.
This file contains 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 makeHTTPRequest = (url, methodType, callback) => { | |
const xhr = new XMLHttpRequest() | |
xhr.open(methodType, url, true) | |
xhr.onreadystatechange = () => { | |
if (xhr.readyState === 4 && xhr.status === 200) { | |
callback(xhr.responseText) | |
} | |
} | |
xhr.send() | |
} | |
const getLogin = (response) => { | |
console.log(JSON.parse(response)) | |
} | |
const url = 'https://api.github.com/users/maecapozzi' | |
makeHTTPRequest(url, 'GET', getLogin) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment