Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Issue with Bluebird.promisify()

See original GitHub issue


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:closed
  • Created 7 years ago
  • Reactions:1
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

athekencommented, Jul 19, 2017

We just released 1.4.0 of the library, which includes Promise 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.

stringbeanscommented, Feb 28, 2017

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”

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found