Last active
August 31, 2017 19:32
-
-
Save doug2k1/ec42764f3a13d47c009b01f504c388a7 to your computer and use it in GitHub Desktop.
HTTP GET request example is JavaScript - https://medium.com/douglas-matoso-english/http-primer-for-frontend-developers-f091a2070637
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
// the request: | |
// GET information about the latest React release on GitHub | |
// we don't need to inform the method (GET is the default), | |
// headers or body (GET request doesn't need one) | |
fetch('https://api.github.com/repos/facebook/react/releases/latest') // the URI | |
.then(response => { | |
// we received the response and print the status code | |
console.log(response.status) | |
// return response body as JSON | |
return response.json() | |
}) | |
.then(json => { | |
// print the JSON | |
console.log(json) | |
}) | |
// on success will log: | |
// 200 | |
// { ... contents of the response body as JSON ... } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment