instagram-node-lib icon indicating copy to clipboard operation
instagram-node-lib copied to clipboard

How to do paging?

Open furtivefelon opened this issue 13 years ago • 3 comments

Hey guys,

First of all thanks a lot for writing this incredibly useful piece of library!

I was just wondering for tags.recent{name:'blue'}), any approved way to do pagination? I understand for complete() callback, you can get the pagination url. However, is there a way of doing pagination within the confines of the library?

Thanks a lot!

Jason

furtivefelon avatar Oct 12 '12 22:10 furtivefelon

Someone have this answer? I researched a lot about it and don't found anything.

lincolnlemos avatar Mar 05 '14 23:03 lincolnlemos

There isn’t a build in method for pagination, but that’s a great idea. I’ll put that on the roadmap.

mckelvey avatar Mar 26 '14 06:03 mckelvey

Even though there is no build-in method, you can easily enable pagination yourself:

var request = require('request');

Instagram.users.recent({
  user_id: 1032088109,
  count: 10,
  complete: getRecent
});

function getRecent(data, page) {

  // work with your data here

  if (page.hasOwnProperty('next_url')) {
    request(page['next_url'], function(err, response, body) {
      var body = JSON.parse(body);
      getRecent(body.data, body.pagination);
    });
  }

};

Amberlamps avatar Jul 16 '14 11:07 Amberlamps