Skip to content

Instantly share code, notes, and snippets.

@ChrisMagnuson
Last active November 20, 2018 04:26
Show Gist options
  • Save ChrisMagnuson/51024fe870dd696ba52d164fc06f9c38 to your computer and use it in GitHub Desktop.
Save ChrisMagnuson/51024fe870dd696ba52d164fc06f9c38 to your computer and use it in GitHub Desktop.
Fetch example with all Promises evaluated
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