Skip to content

Instantly share code, notes, and snippets.

@opn
Created July 29, 2021 13:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save opn/553f83a7c81229ff5fa1932d2d756480 to your computer and use it in GitHub Desktop.
Save opn/553f83a7c81229ff5fa1932d2d756480 to your computer and use it in GitHub Desktop.
The Fetch API Basic Syntax
Check the console.
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