I'm using the when promise library to lift()
my node style callbacks and promisify them...
var nodefn = require('when/node');
var one = nodefn.lift(oneFn),
two = nodefn.lift(twoFn),
three = nodefn.lift(threeFn);
function oneFn(callback){
console.log('one');
callback(null);
}
function twoFn(callback){
console.log('two');
callback(null);
}
function threeFn(callback){
console.log('three');
callback(null);
}
I want to call the functions in a chain, like this:
one().then(two).then(three).done();
But it gives me an error when calling the second callback function:
Uncaught TypeError: undefined is not a function
The error refers to the callback
function within twoFn(callback)
.
What is the correct way to chain these functions together and execute one after the other?