Issue with Bluebird.promisify()
See original GitHub issueIssue Description
Howdy!
Tried promisifying the sendEmailBatch function and it gave me a peculiar error…
I tried using the callback style and it works, but promises are a must-have in my current project.
Here’s the code:
const Promise = require('bluebird');
const postmark = require('postmark');
const client = new postmark.Client(<api_key>);
const messages = []; // array or message objects
const sendEmails = Promise.promisify(client.sendEmailBatch);
return sendEmails(messages);
Unhandled rejection TypeError: this.processRequestWithBody is not a function
at Client.sendEmailBatch (/<project path>/node_modules/postmark/lib/postmark/Client.js:120:14)
Issue Analytics
- State:
- Created 7 years ago
- Reactions:1
- Comments:8 (2 by maintainers)
Top Results From Across the Web
Issue with Bluebird.promisify() #5 - GitHub
Tried promisifying the sendEmailBatch function and it gave me a peculiar error... I tried using the callback style and it works, ...
Read more >Promise.promisify - Bluebird.js
Returns a function that will wrap the given nodeFunction . Instead of taking a callback, the returned function will return a promise whose...
Read more >I'm trying to use the Bluebird's method Promisify and it's not ...
Bluebird's promisify() only works with node-style functions that take a callback as their last argument where that callback takes two ...
Read more >Avoid callbacks in Node.js with Bluebird promises - Applandeo
Bluebird offers better solution than callback based approach, because of it's superior resource management. It requires only basic Node.js ...
Read more >request-promise - npm
promise() or e.g. rp.head(...).promise() which returns the underlying promise so you can access the full Bluebird API.
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
We just released
1.4.0
of the library, which includesPromise
support. To get Promises back, simply call the same client methods without a callback function. The client methods will return a Promise when the callback function is emitted.as an FYI, this is not an issue with postmark.js but an issue with how you’re using
Promise.promisify
. You must bind the correct context to the function you are “promisifying”