Created
September 6, 2018 11:46
-
-
Save max8hine/d62d6bb750e4b40988012f08c59e71b6 to your computer and use it in GitHub Desktop.
nested promise with promise.all
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const promise = num => new Promise((resolve) => { | |
setTimeout(() => { resolve(num) }, 500) | |
}) | |
var arr1 = [1,2,3,4,5].map(x => promise(x)) | |
arr1 | |
var arr2 = [6,7,8,9,0].map(x => promise(x)) | |
arr2 | |
const resolvePromise = async function () { | |
let a = await Promise.all(arr1) | |
let b = await Promise.all(arr2) | |
a | |
b | |
const result = await Promise.all([ a, b ]) | |
result | |
} | |
resolvePromise() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment