I
I
Islam Ibakaev2017-03-14 20:16:47
JavaScript
Islam Ibakaev, 2017-03-14 20:16:47

How can this be predicted?

const onSuccess = data => console.log(data) const onFailure = error
=> console.error(error) (onSuccess).catch(onFailure ) ps already tried promisify, promisifyAll from bluebird, doesn't work. As I understand it, bluebird will promisify the callback api if it is a node style callback api

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Anton Anton, 2017-03-14
@devellopah

Something like that:

cognitoUser.prototype.authenticateUserPromise = function (authenticationDetails) {
return new Promise((resolve, reject) => {
    this.authenticateUser(authenticationDetails, (result)=>{return resolve(result)}, (error) =>{return reject(error)});
});

A
Anton Khmyrov, 2017-03-14
@vivcogit

If I understand correctly, then you need to try this:
Promise.resolve(() => cognitoUser.authenticateUser(authenticationDetails)).then(onSuccess).catch(onFailure )

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question