Created
July 6, 2015 23:54
-
-
Save anonymous/90020023885eab48d7a5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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