JS Get Calls wait Each other
<p>I have a function for send GET http request with request package.
This works good.</p>

<pre><code>//file1.js
var request = require('request');
methods.testcall = function(callback){
    request(url, function (error, response, body) {
        if (!error &amp;&amp; response.statusCode == 200) {
            callback(body)
        }
        if(!error &amp;&amp; response.statusCode == 429){ // Rate limit.., try again 1s
            setTimeout(this(callback), 1000);
        }

    })
};
</code></pre>

<p>In the next file, i call this function two times. I think the 2 request can run in one time. So when the request is arrive then i call the callback function.
In the log i see the result. But, where u see my comment, there i want to wait for ALL testcall(), because i want to be sure in all data arrived to my server.</p>

<pre><code>//file2.js
test.methods.testcall(function(response){
    console.log(response)
});

test.methods.testcall(function(response){
    console.log(response)
});

// Here, i want to wait for all testcall function.
// When all testcall function sent response 
// Im ready to do smtng :)
</code></pre>

<p>How can i wait this two method there?
Thanks so much!</p>