Skip to content

Instantly share code, notes, and snippets.

@salmanx
Created October 18, 2018 05:22
Show Gist options
  • Save salmanx/baa7a1041fba7c38483bbd8878cad8a9 to your computer and use it in GitHub Desktop.
Save salmanx/baa7a1041fba7c38483bbd8878cad8a9 to your computer and use it in GitHub Desktop.
an example how promise work in javascript
const p = new Promise((resolve, reject) => {
setTimeout(() => {
resolve(1);
// reject(new Error('message'));
}, 2000)
});
p.then(result => console.log("Result", result)).catch(err => console.log("Error", err.message))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment