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,824
  • 17
  • 99
  • 186
OiRc
  • 1,602
  • 4
  • 21
  • 60

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
  • 107,747
  • 29
  • 201
  • 177