Created
September 25, 2020 11:59
-
-
Save MohcinBN/36ff58066517f8738123d481469f0430 to your computer and use it in GitHub Desktop.
JavaScript promise example
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 myPromise = new Promise((resolve, reject) => { | |
let connection = false; | |
if (connection) { | |
resolve('Conection is OK'); | |
} else { | |
reject('conection is not OK') | |
} | |
}); | |
myPromise.then((message) => { | |
console.log(message); | |
}).catch((message) => { | |
console.log(message); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment