Skip to content

Instantly share code, notes, and snippets.

@chathurawidanage
Last active March 30, 2018 06:29
Show Gist options
  • Save chathurawidanage/1b634b50d00bd6ab0b7893e10d92e520 to your computer and use it in GitHub Desktop.
Save chathurawidanage/1b634b50d00bd6ab0b7893e10d92e520 to your computer and use it in GitHub Desktop.
Using One Callback which accepts two arguements
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