Skip to content

Instantly share code, notes, and snippets.

@Ibro
Created Dec 24, 2017
Embed
What would you like to do?
JavaScript Promises, road to async/await - https://codingblast.com/javascript-promise-async-await
function sendEmail(params) {
return new Promise(function(resolve, reject) {
mandrillClient.messages.send(
{ params },
function onSuccess(result) {
resolve(result);
},
function onError(error) {
reject(error);
}
);
});
}
async function sendEmail() {
try {
let value = await someFunction('CodingBlast');
console.log(value);
} catch (error) {
console.error('Error', error);
}
}
mainFunction();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment