JSFiddle - React, Tailwind, and code Playground

JavaScript

var aync2 = function() {
  return new Promise(function(resolve, reject){
    // Wait 2s and alert
    setTimeout(function(){ 
      // pretend we got something wrong.
      reject("error");
    }, 1000);
  });
}

aync2().then(function (resp) {
	alert("This will not be called");
}).catch(function(err){
	alert(err);
});