Skip to content

Instantly share code, notes, and snippets.

@doug2k1
Last active August 31, 2017 19:32
Show Gist options
  • Save doug2k1/ec42764f3a13d47c009b01f504c388a7 to your computer and use it in GitHub Desktop.
Save doug2k1/ec42764f3a13d47c009b01f504c388a7 to your computer and use it in GitHub Desktop.
// 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