Skip to content

Instantly share code, notes, and snippets.

@MostlyFocusedMike
Created June 10, 2018 22:10
Show Gist options
  • Save MostlyFocusedMike/cf5133f686af9f16d14388cbe49d2491 to your computer and use it in GitHub Desktop.
Save MostlyFocusedMike/cf5133f686af9f16d14388cbe49d2491 to your computer and use it in GitHub Desktop.
fetch('https://jsonplaceholder.typicode.com/users/1')
.then(function(response) {
console.log(`status: ${response.status}`);
console.dir(response.body);
return response.json() // the important line
})
.then(function(myJson) {
document.write(
`User: ${myJson.name} <br/>
Email: ${myJson.email} <br />
Website: ${myJson.website}`
);
return myJson
})
.then(console.log)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment