Skip to content

Instantly share code, notes, and snippets.

@ericlifka
Created August 31, 2015 15:04
Show Gist options
  • Save ericlifka/5edfea864922ebd4a16c to your computer and use it in GitHub Desktop.
Save ericlifka/5edfea864922ebd4a16c to your computer and use it in GitHub Desktop.
function requestWithTimeout() {
return new Promise((resolve, reject) => {
window.setTimeout(() => reject('timeout - request took more than 30 seconds'), THIRTY_SECONDS);
makeRequest((err, res) => {
if (err) {
reject(err);
}
else {
resolve(res);
}
});
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment