Last active
November 20, 2018 04:26
-
-
Save ChrisMagnuson/51024fe870dd696ba52d164fc06f9c38 to your computer and use it in GitHub Desktop.
Fetch example with all Promises evaluated
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://www.google.com").then(response => response.text().then(text => console.log(text))) | |
fetch("https://www.google.com") | |
.then( | |
response => | |
response.text() | |
.then( | |
text => | |
console.log(text) | |
) | |
) | |
fetch("https://www.google.com") | |
.then( | |
(response) => { | |
response.text() | |
.then( | |
(text) => { | |
console.log(text) | |
} | |
) | |
} | |
) | |
fetch("https://www.google.com") | |
.then( | |
function (response) { | |
response.text() | |
.then( | |
function (text) { | |
console.log(text) | |
} | |
) | |
} | |
) | |
const response = await fetch("https://www.google.com") | |
const text = await response.text() | |
console.log(text) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment