Pergunta

I am using the node.js async package, specifically forEachSeries, to make a series of http requests based on parameters drawn from an 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 of the else if above? This is not technically inside of a loop so continue does not work.

Foi útil?

Solução

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

else if (!response.results) {
    return;
}
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top