3 ms·
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
by gbuk2013 7y ago
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.)