Skip to content

Instantly share code, notes, and snippets.

@chathurawidanage
Created April 5, 2018 05:20
Show Gist options
  • Save chathurawidanage/25aaea5675c5a0d1338cbb0a40eae536 to your computer and use it in GitHub Desktop.
Save chathurawidanage/25aaea5675c5a0d1338cbb0a40eae536 to your computer and use it in GitHub Desktop.
Promise then with two callback recievers
function task(){
return new Promise((resolve,reject)=>{
//do task
if(failed){
reject(err);
}else{
resolve(data);
}
});
}
task().then(data=>{
//handle data
},err=>{
//handle error
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment