News for hackers. Stuff that matters.
Re:A brief look at async-await by art0rz on Monday December 09, 2019 @08:21AM (#21742324)
Parent's code with callbacks would be more like this:

  fetch((err, res) => {
    if (err) {
      // yay - error handling! :)
    }

    res.json((err, myJson) => {
      if (err) {
        // oh no - another error handler :(
      }
      
      // do stuff
    });
  }
fetch.json is async as well. With await the try / catch would just be around both await calls.
Re:A brief look at async-await by gbuk2013 on Monday December 09, 2019 @08:26AM (#21742370)
Yes this is true, as long as your error handling is the same for all calls (not necessarily the case, especially if logging is involved).

I don't actually have a problem with the callback version because it is nice and explicit. But again, I did originally say say that "async/await" was actually a valid use case in this necessarily serial scenario (and is exactly what I do in my article that I linked to). ;)

That said, if I see a chain of serial calls more than a few levels deep it is a code smell that indicates refactoring is necessary. There really is no reason to write code like that unless it's very simple logic. This is why I have never had a problem with "callback hell" even though I write code that is heavily asynchronous (APIs, WebSocket, pub/sub etc.)