0

I have the same problem as Promisify imported class (constructor) with bluebird in ES6 + babel. The accepted answer seems to have a bug but I couldnt comment on that thread (not enough reputation points), so am creating a new question. The bug seems to be in:

var o = new lib.C(); // get object
o.then(function(data){
    // access data
});

I get a run-time error:

~/node_modules/bluebird/js/main/promise.js:114
    return this._then(didFulfill, didReject, didProgress,
                ^ TypeError: undefined is not a function
    at C.Promise.then (~/node_modules/bluebird/js/main/promise.js:114:17)
    at Object.<anonymous> (~/temp/jsex.js:367:3)
    at Module._compile (module.js:460:26)

Can somebody post a working sample? Or point out if I'm missing something?

Community
  • 1
  • 1
Ashok N N
  • 11
  • 2
  • 2
    Notice that [you shouldn't do something that needs a promise in a constructor](http://stackoverflow.com/q/24398699/1048572) anyway. – Bergi May 03 '16 at 21:55
  • I agree, this smells off to me. Is there a reason you can't have a function on that class which returns the promise instead? – dvlsg May 03 '16 at 22:00
  • 1
    This was a bug in my code - try again :P – Benjamin Gruenbaum May 04 '16 at 08:45
  • @Bergi, I'm using node-sqlite3 whose constructor opens the database also. Success or error is conveyed via a callback (if provided) or events. So I want to chain any calls to the successful opening (or failure) of the database. I understand that this is not a good idea but I dont have control over the code in question. – Ashok N N May 05 '16 at 00:28
  • @BenjaminGruenbaum, thanks for confirming, I'll checkout the updated code. – Ashok N N May 05 '16 at 00:29

0 Answers0