Skip to content

Instantly share code, notes, and snippets.

@MohcinBN
Created Sep 25, 2020
Embed
What would you like to do?
JavaScript promise example
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