What is an effective way to make 50 API requests at a time when there is a limit of 10 calls per second (Rotten Tomatoes API)?

I have an application that needs to make 50 to 100 API calls in a loop. Rotten tomatoes have a limit of 10 calls per second. As a result of this, my queries fail between them, and each time I get different results. What is the efficient way to make these 50 queries without exceeding the limit of 10 times / second? Here is my code:

$.each(elem, function (index, item) {

    var $placeholder = $('<div>').appendTo("div.content");

    $.ajax({
        type: 'post' ,
        url: moviesSearchUrl + '&q=' + encodeURI(item) + '&page_limit=1',
        dataType: "jsonp",
        async: false, 
        success: searchCallback
    });

    function searchCallback(data) {
        var movies = data.movies;

        var markup = index + ': '+   movies[0].title + '<img class=" bord" src="' + movies[0].posters.thumbnail + '" /><br/>';

        $placeholder.replaceWith(markup);
    }
});
0
source share
1 answer

, . ( ) -, ( , , ), ( 5 ).

, , , , .

- - , - .

0

All Articles