A Pen by Chris Ferdinandi on CodePen.
Created
July 29, 2021 13:33
-
-
Save opn/553f83a7c81229ff5fa1932d2d756480 to your computer and use it in GitHub Desktop.
The Fetch API Basic Syntax
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
Check the console. |
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
fetch('https://jsonplaceholder.typicode.com/posts').then(function (response) { | |
// The API call was successful! | |
console.log('success!', response); | |
}).catch(function (err) { | |
// There was an error | |
console.warn('Something went wrong.', err); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment