Last active
July 11, 2017 15:08
-
-
Save leonardorifeli/5ee3790d43b307be60e67fede8a5b719 to your computer and use it in GitHub Desktop.
Apresentação Node.js
This file contains 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
async function sendAsync(userId) { | |
let user = await getUser(userId); | |
let profile = await getProfile(user); | |
let account = await getAccount(profile); | |
let report = await getReport(account); | |
let send = sendStatistic(report); | |
console.log(send); | |
} |
This file contains 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
getUser(userId, (error, user) => { | |
getProfile(user, (error, profile) => { | |
getAccount(profile, (error, account) => { | |
getReport(account, (error, report) => { | |
sendStatistics(report, (error) => { | |
... | |
}); | |
}); | |
}); | |
}); | |
}); |
This file contains 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
getUser(userId) | |
.then(getProfile) | |
.then(getAccount) | |
.then(getReport) | |
.then(sendStatistics) | |
.then((success) => { | |
console.log(success); | |
}) | |
.catch((error) => { | |
console.log(error); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment