30 seconds of code

  Back to Home

runPromisesInSeries

functionpromiseintermediate

Runs an array of promises in series.

Use Array.prototype.reduce() to create a promise chain, where each promise returns the next promise when resolved.

const runPromisesInSeries = ps => ps.reduce((p, next) => p.then(next), Promise.resolve());