I'll explain my problem shortly. I am using NodeJS to retrieve response from a url and I have to make multiple request to that URL.
I got only one limit: I can't make more than 10 request for each minute. How can I handle that problem?
I tried to follow that stack overflow response too: Make several requests to an API that can only handle 20 request a minute
but that method its not working because its not awaiting all promise and its giving undefined result
Actually I am using that code but its not awaiting all response, its giving me undefined directly and later all requests are done:
async function rateLimitedRequests(array, chunkSize) {
var delay = 3000 * chunkSize;
var remaining = array.length;
var promises = [];
var addPromises = async function(newPromises) {
    Array.prototype.push.apply(promises, newPromises);
    if (remaining -= newPromises.length == 0) {
        await Promise.all(promises).then((data) => {
            console.log(data);
        });
    }
};
(async function request() {
    addPromises(array.splice(0, chunkSize).map(apiFetch));
    if (array.length) {
        setTimeout(request, delay);
    }
})();
}