Skip to content

Instantly share code, notes, and snippets.

@diego3g
Last active December 11, 2017 16:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save diego3g/2add292924b7e2fdf061b05f5d59ab39 to your computer and use it in GitHub Desktop.
Save diego3g/2add292924b7e2fdf061b05f5d59ab39 to your computer and use it in GitHub Desktop.
const timeout = ms => new Promise((resolve, reject) =>
setTimeout(reject, ms, { timeout: true });
);
Promise.race([api.get('/users/diego3g'), timeout(2000)])
.then(resp => console.log(resp))
.catch(err => console.log(err));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment