I
I
Igor Peregudov2017-03-25 22:39:12
JavaScript
Igor Peregudov, 2017-03-25 22:39:12

How to call given vk api method in loop with 340ms delay?

There is the following code:

var owner_id = -51016572;
var offsetPost = 0;
var wallPostsArray = [];
var totalPosts;

VK.Api.call('wall.get', {owner_id: owner_id, count: 100, offset: offsetPost, filter: 'owner'}, function(res) {
    if(res.response) {
        totalPosts = res.response[0]; //Всего постов в паблике от имени группы

        for(var i = 1; i < res.response.length; i++){
            wallPostsArray.push(res.response[i]); //Массив объектов состоящий из постов группы
        }

    }else if(res.error){
        console.log(res.error);
    }
});


Please tell me how to call the "wall.get" method with a delay in the loop, adding +100 to "offsetPost" I
tried everything, but it doesn't work

Answer the question

In order to leave comments, you need to log in

2 answer(s)
H
hufawoso, 2017-03-25
@hufawoso

setInterval(() => {
   offsetPost += 100;
  VK.Api.call('wall.get',
  ....
}, 340)

V
Vitaly, 2017-03-26
@vshvydky

totalPosts = res.response[0]; there is clearly some kind of garbage, there is a response.totalCount like. And you look at some non-existent topic.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question