Skip to content

Instantly share code, notes, and snippets.

@leonardorifeli
Last active July 11, 2017 15:08
Show Gist options
  • Save leonardorifeli/5ee3790d43b307be60e67fede8a5b719 to your computer and use it in GitHub Desktop.
Save leonardorifeli/5ee3790d43b307be60e67fede8a5b719 to your computer and use it in GitHub Desktop.
Apresentação Node.js
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);
}
getUser(userId, (error, user) => {
getProfile(user, (error, profile) => {
getAccount(profile, (error, account) => {
getReport(account, (error, report) => {
sendStatistics(report, (error) => {
...
});
});
});
});
});
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