Guest User

Untitled

a guest
Jun 27th, 2016
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.21 KB | None | 0 0
  1. function timeout(ms){
  2. return new Promise((resolve) => {
  3. setTimeout(resolve, ms);
  4. });
  5. }
  6.  
  7. Promise.race([
  8. timeout(3 * 1000),
  9. fetch('xxx.com')
  10. ]).then((res) => {
  11. console.log("First to finish: ", res);
  12. });
Add Comment
Please, Sign In to add comment