Question: Promisifying mandrill-api
See original GitHub issueJust getting started with Bluebird and trying to figure out the best way to promisify use of the sendTemplate call on the mandrill-api. It’s not a standard node.js callback design in that it takes 2 callback as the last parameters (first as a success callback and the second being a failure callback). For example (taken from the mandril docs)
mandrill_client.messages.sendTemplate({"template_name": template_name, "template_content": template_content, "message": message, "async": async, "ip_pool": ip_pool, "send_at": send_at}, function(result) {
// SUCCESS
console.log(result);
/*
[{
"email": "recipient.email@example.com",
"status": "sent",
"reject_reason": "hard-bounce",
"_id": "abc123abc123abc123abc123abc123"
}]
*/
}, function(e) {
// FAILURE
// Mandrill returns the error as an object with name and message keys
console.log('A mandrill error occurred: ' + e.name + ' - ' + e.message);
// A mandrill error occurred: Unknown_Subaccount - No subaccount exists with the id 'customer-123'
});
Any help/suggestions would be great. At a minimum we’d like to call this from inside a method wrapped in a Promise.method
@pazrul to follow
Issue Analytics
- State:
- Created 9 years ago
- Comments:7 (2 by maintainers)
Top Results From Across the Web
Messages | Mailchimp Transactional API Reference
Returns information about an export job. If the export job's state is 'complete', the returned data will include a URL you can use...
Read more >Promisifying API callbacks - How to properly resolve or reject
Something like that: function getCurrentPositon(options){ return new Promise(function(resolve, reject){ navigator.geolocation.
Read more >Using the Mandrill API in my own website - Codecademy
I now have the mailchimp-mandrill-api.js library needed to start working with Mandrill offline. Popular free courses. Course ...
Read more >Node.js util.promisify() Method - GeeksforGeeks
promisify () method defines in utilities module of Node.js standard library. It is basically used to convert a method that returns responses ...
Read more >Open Source Used In slido-test 22.06 - Cisco
questions or wish to receive a copy of any source code to which you may be entitled under ... 1.607 mandrill-api 1.0.45 ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
The promise constructor works pretty well with dual callback apis.
If it’s just one method then you can do what @wavded said.
If you want to promisify whole module that has this convention, then use a custom promisifier using the
promisifier
option: