Created
June 14, 2017 02:06
-
-
Save bluepnume/70d26dd747c04215868521ed4e92da88 to your computer and use it in GitHub Desktop.
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 getPerson(name) { | |
| let result = ajax('/api/person/' + name); | |
| return result.person; | |
| } | |
| function getPersonDateOfBirth(name) { | |
| let person = getPerson(name); | |
| return person.dob; | |
| } | |
| function getPerson(name, callback) { | |
| return ajax('/api/person/' + name, function(err, result) { | |
| if (err) { | |
| callback(err); | |
| } else { | |
| callback(null, result.person); | |
| } | |
| }); | |
| } | |
| function getPersonDateOfBirth(name) { | |
| return getPerson(name, function(err, person) { | |
| if (err) { | |
| callback(err); | |
| } else { | |
| callback(null, person.dob); | |
| } | |
| }); | |
| } | |
| function getPerson(name) { | |
| return ajax('/api/person/' + name).then(function(result) { | |
| return result.person; | |
| }); | |
| } | |
| function getPersonDateOfBirth(name) { | |
| return getPerson(name).then(function(person) { | |
| return person.dob; | |
| }); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment