PromisesInSeries
function that takes an array of asynchronous functions and sequentially (the next one starts when the previous one has finished) calls them, passing the result of calling the previous function as arguments
function promisesInSeries(asyncFns) {
let result;
return new Promise((resolve, reject) => {
for(const fn of asyncFns){
resolve(fn)
.then(data => fn(data))
}
})
}
I only get the results of the first function. How to call all functions from an array and, as a result, return the last value?