Callback after for-loop finishes in node.js

前端 未结 3 1506
被撕碎了的回忆
被撕碎了的回忆 2020-12-15 13:10

I need some help with the asynchronous nature of node.js. I have a for loop, which collects data from the database. \"result\" is an array, which should then be returned to

3条回答
  •  难免孤独
    2020-12-15 14:05

    With v1.5.2 of Async.js, It is each.

    each(arr, iterator, [callback])
    

    arr - An array to iterate over.
    iterator(item, callback) - A function to apply to each item in arr.
    callback(err) - Optional. A callback which is called when all iterator functions have finished, or an error occurs.

提交回复
热议问题