News for hackers. Stuff that matters.
Re:Async and Await by lhecker on Thursday June 02, 2016 @01:49PM (#11824528)
And the "correct" code would be this for instance:

  export default function getUsers () {
    return getUsers().then(users => {
      return filterUsersWithFriends(users)
        .catch(err => trySomethingElse(users));
    });
  }
Or if you like one-liners:

  export default function getUsers () {
    return getUsers().then(users => filterUsersWithFriends(users).catch(err => trySomethingElse(users)));
  }
Re:Async and Await by eyko on Thursday June 02, 2016 @05:37PM (#11826277)
You're still nesting. Considering the whole point the author made was that something went wrong with `filterUsersWithFriends`, then you would simply handle that in the next `.then`... So something like:

  export default function getUsers () {
    return getUsers()
      .then(users => filterUsersWithFriends)
      .then(getUsersLikes, trySomethingElse);
  }
would have been more than enough.
Re:Async and Await by md224 on Thursday June 02, 2016 @06:44PM (#11826736)
I think the problem with your solution is that trySomethingElse won't have access to the users variable unless the filterUsersWithFriends rejection explicitly passes it through.
Re:Async and Await by taranw85 on Thursday June 02, 2016 @02:14PM (#11824771)
That still doesn't look as nice as await.
Re:Async and Await by untog on Thursday June 02, 2016 @01:51PM (#11824547)
(EDIT: ahem, that'll teach me to not look at the code I'm editing)
Re:Async and Await by savanaly on Thursday June 02, 2016 @01:54PM (#11824584)
I dont think this quite works. For one thing, the users references won't be available when you try to use it in trySomethingElse(users), because it's scoped to that little arrow function above. For another, it has the effect of catching any error thrown by getUsers() and calling trySomethingElse, whereas the original code simply did nothing in that case.
Re:Async and Await by davej on Thursday June 02, 2016 @01:55PM (#11824599)
This isn't correct, `users` would be undefined.