Created
June 10, 2018 22:10
-
-
Save MostlyFocusedMike/cf5133f686af9f16d14388cbe49d2491 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
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