Created
July 20, 2020 00:20
-
-
Save twolfson/154c0671c148884e6a6fa6a19ad782da to your computer and use it in GitHub Desktop.
Exploration for familiarization with Promise API
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
(async function () { | |
// Define a Promise generator | |
function getPromise() { | |
// return Promise.resolve('done2'); | |
// return Promise.reject('throw text '); | |
return new Promise((resolve, reject) => { | |
setTimeout(() => { | |
resolve('done'); | |
}, 300 /* ms */); | |
}); | |
} | |
let retVal = await Promise.allSettled([ | |
getPromise(), | |
getPromise(), | |
Promise.reject('foo'), | |
]); | |
console.log(retVal); | |
}()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment