Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

support for returning pagination data

  • Loading branch information...
commit 90487b982fc15dd4cba787258be72206c4324071 1 parent a9396a2
@Swizec authored
Showing with 17 additions and 9 deletions.
  1. +9 −2 index.js
  2. +8 −7 tests.js
View
11 index.js
@@ -33,10 +33,17 @@ InstagramClient.prototype.fetch = function (path, params, callback) {
res.on('end', function () {
var response = JSON.parse(raw);
+ var pagination = null;
+ if (typeof(response['pagination']) != 'undefined') {
+ pagination = response['pagination'];
+ }
+
if (response['meta']['code'] == 200) {
- callback(response['data'], null);
+ callback(response['data'],
+ null,
+ pagination);
}else{
- callback(response['meta'], response['meta']['code']);
+ callback(response['meta'], response['meta']['code'], pagination);
}
});
});
View
15 tests.js
@@ -50,7 +50,7 @@ exports.testMediaSearch = function (test) {
exports.testTagsSearch = function (test) {
test.expect(2);
- instagram.tags.search('snow', function (tags, error) {
+ instagram.tags.search('snow', function (tags, error, pagination) {
test.ok((tags.length > 0));
test.equal(error, null, "Returned an error");
@@ -59,17 +59,18 @@ exports.testTagsSearch = function (test) {
}
exports.testTagsMedia = function (test) {
- test.expect(8);
+ test.expect(12);
var max_id = 0, min_id = 0;
- var callback = function (media, error) {
+ var callback = function (media, error, pagination) {
test.ok((media.length > 0));
+ test.ok((pagination != null));
test.equal(error, null);
}
- instagram.tags.media('snow', function (media, error) {
- callback(media, error);
+ instagram.tags.media('snow', function (media, error, pagination) {
+ callback(media, error, pagination);
max_id = media[0].id;
min_id = media[media.length-1].id;
@@ -77,8 +78,8 @@ exports.testTagsMedia = function (test) {
instagram.tags.media('snow', {max_id: max_id}, callback);
instagram.tags.media('snow', {min_id: min_id}, callback);
instagram.tags.media('snow', {max_id: max_id, min_id: min_id},
- function (media, error) {
- callback(media, error);
+ function (media, error, pagination) {
+ callback(media, error, pagination);
test.done();
});
}
Please sign in to comment.
Something went wrong with that request. Please try again.