In Node.js v7.8.0 I have a module foo.js
:
class Foo {
async bar() { return 'bar' }
}
In the main module, app.js
I assign Bluebird a global promise:
global.Promise = require('bluebird')
.
And in `app.js' I have:
const Foo = require('./foo);
let foo = new Foo();
foo.bar().tap(res => console.log(res));
I assumed that since I replaced the Bluebird global promise, calling the async function will return the Bluebird promise (which has .tap
), but apparently I'm wrong because I get the error:
TypeError: foo.bar(...).tap is not a function
Is there a way to achieve what I want?
source
share