Return values from arrow function inside function JS

  function, javascript, return-value

This is my code, I’m trying to return entries as a return-value for listDir
to get it from outside, but it’s not working.

function listDir(path){
    var files;
    window.resolveLocalFileSystemURL(path,
      function (fileSystem) {
        let _this = this;
        var reader = fileSystem.createReader();
        reader.readEntries( (entries) => {
            _this.files = entries;
        },
          (err)=>(console.log(err))
        );
      },(err)=>(console.log(err))
    );
    return files;
}

What is wrong I can not return value of entries
It always undefined.

Source: Ask Javascript Questions

LEAVE A COMMENT