I don't know if SO is the right place for such a question.
I know a bit Promises
, and I use them in a Node/Express
environment to 'fix' the asynchronous behavior of Node
when querying database (= Wait for DB answer, then do something).
However, the more I use them, the less I know when not use them.
For example, I wrote a piece of code like this (for a local script querying Google Matrix API
)...
....
for (var i = 0; i < rows.length; i++) { // loop over a CSV file by line
var cell = rows[i].split(/;/)
var origin = cell[1]
var destination = cell[2]
var id = cell[0]
Promise.all([origin, destination, id]).then((p) => {}
...
I don't know if using here a Promise.all
makes sense at all...
Is there a rule to know? A behavior I do not get?
Say differently, when do I know there is a "risk" that my script runs a function
without its right argument (argument
being returned from another function
which is not "over") ...?
Thanks.