cannot denodeify methods in node-ftp module

131 views
Skip to first unread message

Quoc Lam

unread,
Mar 15, 2014, 12:15:39 AM3/15/14
to q-con...@googlegroups.com

Hi,

I am new to both node.js and promise style function call. By looking at an denodeify example at http://runnable.com/Ulatc0QnzUgUAAAK/adapting-node-js-with-q-for-promises, I am trying to denodeify the methods of the node.js node-ftp module as following:

var ftp = require('ftp');
var q = require('q');
var ftpClient = new ftp();
ftpClient.on('ready', function() {
    var ftpList = q.denodeify(ftpClient.list);
    ftpList().then(function(list) {
        console.log(list);
    }.then(null, function(err) {
        console.log(err);
    }).done(function() {
        ftpClient.end();
    });
});
ftpClient.connect();

However, when running that code with node, it shows the error "list error: TypeError: Object # has no method '_pasv'"

I am not sure what's wrong with that piece of code. Does anyone know what's wrong with that? Can you point me some way to debug/troubleshoot the cause of that error message?

Thanks,

Quoc


Jason Crawford

unread,
Mar 17, 2014, 6:20:53 PM3/17/14
to q-con...@googlegroups.com
I think you want Q.nbind(ftpClient.list, ftpClient), not Q.denodeify(ftpClient.list). The former will make sure that the 'list' method is called with the ftpClient as its context.


Hope that helps,
Jason

--
Blog: http://blog.jasoncrawford.org  |  Twitter: @jasoncrawford




--
You received this message because you are subscribed to the Google Groups "Q Continuum (JavaScript)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to q-continuum...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages