Http request inside a loop

前端 未结 2 578
误落风尘
误落风尘 2021-01-06 11:36

I\'m having some troubles in making a HTTP request inside a loop.

Let me explain what I have....

I make an http GET to retrieve some values and then I need t

2条回答
  •  谎友^
    谎友^ (楼主)
    2021-01-06 12:29

    Did you forget to use your looping variables i and j. The code above will keep making requests with body[0] as src and body[1] as dest for the duration of the loop provided body has length >= 2. Try using https://github.com/caolan/async#forEachOf or https://github.com/caolan/async#each for calling async functions in a loop.

提交回复
热议问题