Created
April 5, 2018 05:20
-
-
Save chathurawidanage/25aaea5675c5a0d1338cbb0a40eae536 to your computer and use it in GitHub Desktop.
Promise then with two callback recievers
This file contains hidden or 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
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