Last active
September 21, 2018 06:40
-
-
Save chulman444/8cb7a35d05d886edb3f497746cda5b69 to your computer and use it in GitHub Desktop.
I prefer async and await.
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
const myRequest = new Request(window.location.origin + "/test"); | |
async function callRequest() { | |
res_p = await fetch(myRequest); | |
res_text = await res_p.text(); | |
return res_text | |
} | |
callRequest().then(val => { | |
console.log(val); | |
}); |
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
const myRequest = new Request(window.location.origin + "/test"); | |
fetch(myRequest) | |
.then(res => { | |
// console.log(res.json()); | |
res.text() | |
.then(val => { | |
console.log(val); | |
}) | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment