Re:How to chain multiple functions in JavaScript properly wi...
by Lyrkan on Tuesday August 13, 2019 @08:22AM
(#20685057)
Yep, the comment is wrong, this line won't wait for anything but rather check that both calls resolved to a truthy value.
There are also some other incorrect things in that post that makes the code overly complicated, like:
> Every async function needs a new Promise, and needs to resolve()
That's definitely not needed unless you call something that runs asynchronously without being `async` or returning a standard `Promise` (in which case you could probably use a generic wrapper to convert them to `Promise` objects and avoid having to do that everytime).
Re:How to chain multiple functions in JavaScript properly wi...
by xntrk on Tuesday August 13, 2019 @07:45AM
(#20684772)
My understanding was that each await would "block" (creates a new function in a then block that will get execed once the promise resolves).
if you wanted to run the two in parallel you would have to Promise.all([promise1, promise2]).then(fn)
I'm not sure this is correct. Getting to this line already implies they are done, as the await will block. You could just put res.send() on this line no?