Skip to content

Instantly share code, notes, and snippets.

@jcyh0120
Created May 12, 2017 04:05
Show Gist options
  • Save jcyh0120/75a3dd0a3997c159042dbf976816e725 to your computer and use it in GitHub Desktop.
Save jcyh0120/75a3dd0a3997c159042dbf976816e725 to your computer and use it in GitHub Desktop.
Example Promise
var result = FunA(test)
.then(function(){
return FunB();
}).catch(function(error){
//handle error here???
console.error(error);
});
function FunA(test){
return new Promise(function(resolve,reject){
if(test){
resolve(test);
} else {
reject(test);
}
})
}
function FunB(){
return FunOther().then(function(result){
return result;
}).catch(function(err){
//handle error here???
console.error(err);
})
}
function FunOther(other){
return new Promise(function(resolve,reject){
if(other){
resolve(other);
} else {
reject(other);
}
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment