Chạy nhiều promise song song và tuần tự
- If you want to run than in parallel, then we use
.map()
to kick everything off, thenPromise.all()
to gather them back up again. - If you want to run them sequentially, create a fake Promise to start then chain. Then call
.reduce()
to run each promise run in sequence. - Nguồn:: How to run async JavaScript functions in sequence or parallel