Skip to content

Instantly share code, notes, and snippets.

@Ibro
Created December 24, 2017 13:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Ibro/c63052a39c2710fda30516bbb9094c2f to your computer and use it in GitHub Desktop.
Save Ibro/c63052a39c2710fda30516bbb9094c2f to your computer and use it in GitHub Desktop.
JavaScript Promises, road to async/await - https://codingblast.com/javascript-promise-async-await
function someFunction(value, error) {
return new Promise(
function (resolve, reject) {
if (value) {
resolve(value);
} else {
reject(error);
}
});
}
async function mainFunction() {
let value = await someFunction('CodingBlast');
console.log(value);
}
mainFunction();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment