Last active
January 9, 2018 15:44
-
-
Save definitelycarter/6499e32334468b669505be4c61066cb4 to your computer and use it in GitHub Desktop.
example without using promises
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
let getUserFromEmail = (email, cb) => { | |
$service.findUser({ email }, (err, user) => { | |
if(err) { | |
return cb(err); | |
} else if(user == null) { | |
return cb(new Error('The user was not found')); | |
} | |
console.log('User found'); | |
return cb(undefined, user); | |
}); | |
} | |
console.log('Fetching user'); | |
getUserFromEmail('[email protected]', (e, user) => { | |
if (e) { | |
console.log('Error occurred'); | |
} else { | |
console.log(user.email); // user@email.com | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment