Last active
March 30, 2018 06:29
-
-
Save chathurawidanage/1b634b50d00bd6ab0b7893e10d92e520 to your computer and use it in GitHub Desktop.
Using One Callback which accepts two arguements
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(callback){ | |
//do task | |
if(failed){ | |
callback(error,null); | |
}else{ | |
callback(null,error); | |
} | |
} | |
//calling task | |
task((err,data)=>{ | |
if(err){ | |
//handle error | |
}else{ | |
//handle data | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment