SHARE
TWEET

Untitled

a guest Jul 18th, 2019 53 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var promise = new Promise(function(resolve, reject) {
  2.     reject('This statement is rejected');
  3. })
  4.  
  5. promise
  6.     .then(function(successMessage) {
  7.         console.log(successMessage);
  8.     }, function(errorMessage) {
  9.       //Error handler is invoked since the request failed for some reason and is handled here
  10.         console.log(errorMessage); // This is executed
  11.     })
  12.    
  13.     //OUTPUT
  14.     This statement is rejected
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top