Skip to content

Instantly share code, notes, and snippets.

@Christopher2K
Last active April 9, 2018 21:16
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 Christopher2K/5ee9d477e9556eb9bd95a8e3490f0d83 to your computer and use it in GitHub Desktop.
Save Christopher2K/5ee9d477e9556eb9bd95a8e3490f0d83 to your computer and use it in GitHub Desktop.
const url = 'http://myurl.com';
const options = { method: 'GET' };
// Appel de l'API Fetch
fetch(url, options)
.then((response) => response.json()) // Récupération des données
.then((data) => { // Callback de succès
window.alert('SUCCESS');
console.log(data);
})
.catch((error) => { // Callback d'erreur
window.alert('ERROR');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment