0

このコードに何か問題がありますか? 429 応答を取得し、API によってレート制限されています。これは私のループのせいですか?

function getCat(from_locat){

var art_count = 0,
section_to_display = '';
if (!from_local) {
    $.getJSON('/api/v2/help_center/sections.json').success(function(data) {
        sections = data.sections;
        sec_count = data.count;
    }).then(function() {
        $.each(sections, function(section) {
            if (document.location.toString().match(sections[section].id) !== null) {
                    sections[section].isactive = 'active'; // section heading active?
                }
                $.getJSON('/api/v2/help_center/sections/' + sections[section].id + '/articles.json?draft=false').success(function(data) {
                    $.each(data.articles, function() {
                        if (document.location.toString().match(this.id) !== null) {
                            this.isactive = 'active'; // activate this
                            section_to_display = this.section_id;
                        }
                    });
                    sections[section].articles = data;
                    art_count++;
                    if (art_count === sec_count) {
                        renderNav(sections, section_to_display);
                        if (typeof(Storage) !== "undefined") {
                            var cache_expiry = moment().add(20, 'minutes').format('X');
                            sessionStorage.setItem('cache_expiry', cache_expiry);
                            sessionStorage.setItem('sections', JSON.stringify(sections));
                        }
                    }
                });

});

4

1 に答える 1