4 ms·
It's more obvious if you have multiple levels. function getUserFriends(userName) { return db.users.findOne({ name: userName }) .then(function (user
by prezjordan 13y ago
It's more obvious if you have multiple levels.
function getUserFriends(userName) {
return db.users.findOne({ name: userName })
.then(function (user) {
return db.friends.find({ userId: user.id });
})
.then(function (friends) {
return somethingAsync(friends);
});
}
- mjackson 13y agoI don't ever write code like this personally. The multiple levels make it more difficult to reason about, IMO.