12-15-2021, 03:17 AM
(12-14-2021, 10:40 PM)ryo Wrote: So I end up wrapping everything I make in Node into "promise.then.then.then.then..."
Just use async / await to avoid nesting callbacks .
(12-14-2021, 10:40 PM)ryo Wrote: If I don't wrap everything into promises, thought process always goes like "WTF, I just solved this one bug only to create 5 new bugs!?" (refresh) "Oh, it got fixed by itself." (refresh) "NOW THERE ARE 20 NEW BUGS!?".
That doesn't sound right. Only a few things are asynchronous in Node.js like network requests and file operations (but those can be done synchronously too), because like you said async isn't always needed in programming. Asynchronous methods return promises and only with those you have to use .then or await if you want to do something after they complete.