Node.js: How to run asynchronous code sequentially

前端 未结 6 2065
眼角桃花
眼角桃花 2021-01-03 02:37

I have this chunk of code

User.find({}, function(err, users) {
    for (var i = 0; i < users.length; i++) {
        pseudocode
        Friend.find({
              


        
6条回答
  •  甜味超标
    2021-01-03 03:22

    You can also take a look at the Async JavaScript library: Async It provides utility functions for ordering the execution of asynchronous functions in JavaScript.

提交回复
热议问题