Here is my node js code:
var ResponseData = { str: "" };
function GetFilesList( FolderName, ResponseData )
{
    fs.readdir( FolderName, GetFilesList_callback );
}
function GetFilesList_callback( Err, Files )
{   
    if( Err ) throw Err;
    for( var Idx in Files )
    {
        var Entry = "File " + Idx + " =" + Files[ Idx ] + "=";
        ResponseData.str += Entry;
        console.log( Entry );
    }
}
After calling GetFilesList() function, ResponseData.str does not contain the file names although I see them in the concole.
Based on answers got here, I modified the functions as following:
function GetFilesList( FolderName, ResponseData )
{
    var prom = new Promise( function( resolve, reject )
             { fs.readdir( FolderName, GetFilesList_callback ) } );
    prom.then( function( Files )
                 {
                    ResponseData.str += "x";
                    console.log( "after_promise" );
                 } )
}
The "then" part is not executed. Strange enough, if a I place a second request to server (i.e. a simply page refresh in browser) I see just then that ResponseData.str has the file names I expect (but not the "x"es).
 
     
     
    