Skip to content

Instantly share code, notes, and snippets.

Created July 6, 2015 23:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save anonymous/90020023885eab48d7a5 to your computer and use it in GitHub Desktop.
Save anonymous/90020023885eab48d7a5 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Test Promises</title>
</head>
<body>
<script>
var promise = new Promise(function(resolve, reject) {
console.log('begin doing async part of promise');
if (true) {
resolve("stuff worked");
}
else {
reject(Error("it broke"));
}
});
promise.then(function(result) {
console.log(result);
}, function(err) {
console.log(err);
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment