-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue with Bluebird.promisify() #5
Comments
As a workaround for now, I am using this hack: return new Promise((resolve, reject) => {
client.sendEmailBatch(messages, (error, success) => {
if (error) reject(error);
resolve(success);
});
}); |
Hey @cvburgess I have implemented something very similar using a corresponding function on q.js Essentially Q has two functions for wrapping node style functions: Q.denodeify and Q.nbind Denodeify should be used for static functions and nbind should be used for functions that are part of an object and make use of Here is my code:
Obviously, this doesn't directly apply to you but you will need to find the corresponding function to Q.nbind in Bluebird. |
Hey folks, I just want to acknowledge this issue. I'll have a look at the code and see if it's an issue related to the prototype for |
I was able to work with bluebird by doing the following: const Promise = require('bluebird'), // eslint-disable-line no-shadow
postmark = require('postmark');
const client = new postmark.Client(postmarkConfig.apiToken),
sendEmailWithTemplate = Promise.promisify(client.sendEmailWithTemplate, {context: client});
// Usage
// Returns a promise
sendEmailWithTemplate({
From: from,
To: to,
TemplateId: postmarkConfig.templates[type],
TemplateModel: locals
}); |
as an FYI, this is not an issue with postmark.js but an issue with how you're using |
I will try this in my code and close this issue if it works - thanks @stringbeans :) |
We just released |
Thank you @atheken I will update tonight :D |
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:
The text was updated successfully, but these errors were encountered: