Last active
April 9, 2018 21:16
-
-
Save Christopher2K/5ee9d477e9556eb9bd95a8e3490f0d83 to your computer and use it in GitHub Desktop.
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
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