Created
October 25, 2019 18:08
-
-
Save greathmaster/9d55c7c3be440a6ab82cae030015537e to your computer and use it in GitHub Desktop.
Example of Javascript Fetch and Promise
This file contains 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
function func() { | |
let promise = fetch('https://api.github.com/zen') | |
return promise.then((successResponse) => { | |
console.log(successResponse) | |
return successResponse.text(); | |
}) | |
} | |
func().then((resp) => {console.log(resp)}) | |
.catch((resp) => console.log(resp)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment