I want to create one Promise that, internally, calls a series of asynchronous methods in sequence and returns the results of these methods, concatenated in an ordered Array, once the last method returns.
I was trying this:
const getArray = function (thisArray) {
    return new Promise ( function (resolve, reject) {
        if (thisArray.length < 3) {
            setTimeout(function() {
                console.log('adding element');
                thisArray.push(thisArray.length);
                getArray(thisArray);
            },  1000); 
        } else {
            console.log(thisArray);
            console.log('resolving');
            resolve(thisArray);
        }
    });
}
getArray([]).then(function(data) {
    console.log('thened');
    console.log(data);
})but it doesn't ever calls the then(). How can I do this?
 
     
    