0

I'm using this script for listing all files in a server

var PromiseFtp = require('promise-ftp');

  var ftp = new PromiseFtp();
  ftp.connect({host: ipServer, user: user, password: password})
  .then(function (serverMessage) {
    return ftp.list('/directory/',false);
  }).then(function () {
    return ftp.end();
  });

How I can print all files of the directory?

halfer
  • 19,471
  • 17
  • 87
  • 173
OiRc
  • 1,540
  • 4
  • 18
  • 55

1 Answers1

1

Maybe something like this:

  var ftp = new PromiseFtp();
  ftp.connect({host: ipServer, user: user, password: password})
  .then(function (serverMessage) {
    return ftp.list('/directory/',false);
  }).then(function (list) {
    console.log(list);
    return ftp.end();
  });

But make sure to also add some rejections handlers and handle errors correctly. See this for more info: Should I refrain from handling Promise rejection asynchronously?

Community
  • 1
  • 1
rsp
  • 100,622
  • 26
  • 191
  • 167