Skip to content

Instantly share code, notes, and snippets.

@MohcinBN
Created September 25, 2020 11:59
Show Gist options
  • Save MohcinBN/36ff58066517f8738123d481469f0430 to your computer and use it in GitHub Desktop.
Save MohcinBN/36ff58066517f8738123d481469f0430 to your computer and use it in GitHub Desktop.
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