Skip to content

Instantly share code, notes, and snippets.

@jpina
Created November 25, 2015 11:04
Show Gist options
  • Save jpina/4871f993ace58f4d0893 to your computer and use it in GitHub Desktop.
Save jpina/4871f993ace58f4d0893 to your computer and use it in GitHub Desktop.
01 Promise API
var promise = new Promise(function(resolve, reject) {
// do a thing, possibly async, then…
if (/* everything turned out fine */) {
resolve("Stuff worked!");
}
else {
reject(Error("It broke"));
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment