Skip to content

Instantly share code, notes, and snippets.

@pc-magas
Created August 5, 2019 10:34
Show Gist options
  • Save pc-magas/580e023f2c0a5c4cd8c1e41706a4fb03 to your computer and use it in GitHub Desktop.
Save pc-magas/580e023f2c0a5c4cd8c1e41706a4fb03 to your computer and use it in GitHub Desktop.
const mandrill = require('node-mandrill')('ThisIsMyDummyApiKey');
const sendEmail = async () => {
return await mandrill('/messages/send', {
message: {
to: [{email: 'git@jimsc.com', name: 'Jim Rubenstein'}],
from_email: 'you@domain.com',
subject: "Hey, what's up?",
text: "Hello, I sent this message using mandrill."
}
});
}
/**
* How I Need to refactor my method in order to handle errors with the following piece of code?
*/
try{
const response = await sendEmail()
console.log(response)
} catch(e) {
console.error(e);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment