Is there an equivalent instruction to continue using node.js async forEachSeries?

I use the async node.js package, especially forEachSeries, to create a series of HTTP requests based on the parameters received from the array. In the callback of each request, I have some if / else statements to respond to different types of responses.

// This is the callback of a GET request inside of a forEachSeries function(error, response) { if (response.results) { // Do something with results } else if (!response.results) { // Would like to use a continue statement here, but // this is not inside of a loop } else { // Do something else } } 

Is there an equivalent to β€œcontinue” that I can use inside else if above? It is not technically inside the loop, so continue does not work.

+6
source share
1 answer

Since this is just a function, you should be able to return from it to have the same effect:

 else if (!response.results) { return; } 
+5
source

Source: https://habr.com/ru/post/912935/


All Articles