Skip to content

Instantly share code, notes, and snippets.

@Ibro
Created December 24, 2017 13:05
Embed
What would you like to do?
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