In the Q documentation:
If you work with functions that use the Node.js pattern callback, where the callbacks are in the form of a function (err, result), Q provides several useful utility functions for converting between them. The most obvious are probably Q.nfcall and Q.nfapply
What does this mean that nfcall() expects a Node-style function(cb) , which calls cb(error, result) . Therefore, when you write:
Q.nfcall(mytest) .then( function(value){ console.log(value); });
Q expects the call to mytest pass the callback with (error, value) and Q , and then calls your next callback with value . So your code should look something like this (here Plunkr ):
function mytest(cb) { console.log('In mytest'); cb(null, 'aaa'); } Q.nfcall(mytest) .then( function(value){ console.log('value', value); });
You can study the nfcall () test cases to gain a deeper understanding of how this should be used.
Oleksandr.Bezhan
source share