Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function timeout(ms){
- return new Promise((resolve) => {
- setTimeout(resolve, ms);
- });
- }
- Promise.race([
- timeout(3 * 1000),
- fetch('xxx.com')
- ]).then((res) => {
- console.log("First to finish: ", res);
- });
Add Comment
Please, Sign In to add comment