javascript - JS and SoundCloud API - inconsistent pagination results -
i'm using soundcloud
api fetch data (tracks), 6 @ time (the result can huge, pagination needs, i'm fetching batches of 6 results each time). i'm using code fetch first 6 tracks, along next_href
cursor:
sc.get('/tracks', { q: searchinput, limit: 6, linked_partitioning: 1 }).then(function (tracksresponse) { console.log(tracksresponse); });
this fine, 6 results , link fetch next batch
:
object {collection: array[6], next_href: "https://api.soundcloud.com/tracks?linked_partition…d6184b18e16c81&offset=6&q=dream%20theater&limit=6"}
then attach next_href
button
witch click fires ajax
request link provided previous result. code of ajax
is:
$("#nextresults").click(function(){ clearprevresults(); $.ajax({url: nextbatch, success: function(result){ console.log(result); nextbatch = result.next_href; }}); });
the problem i'm not getting 6 results back. problem code? these results i'm getting:
object {collection: array[6], next_href: "https://api.soundcloud.com/tracks?linked_partition…d6184b18e16c81&offset=6&q=dream%20theater&limit=6"} logic.js:56 [object, object, object, object, object, object] logic.js:114 object {collection: array[5], next_href: "https://api.soundcloud.com/tracks?linked_partition…6184b18e16c81&offset=12&q=dream%20theater&limit=6"} logic.js:114 object {collection: array[6], next_href: "https://api.soundcloud.com/tracks?linked_partition…6184b18e16c81&offset=18&q=dream%20theater&limit=6"} logic.js:114 object {collection: array[6], next_href: "https://api.soundcloud.com/tracks?linked_partition…6184b18e16c81&offset=24&q=dream%20theater&limit=6"} logic.js:114 object {collection: array[6], next_href: "https://api.soundcloud.com/tracks?linked_partition…6184b18e16c81&offset=30&q=dream%20theater&limit=6"} logic.js:114 object {collection: array[5], next_href: "https://api.soundcloud.com/tracks?linked_partition…6184b18e16c81&offset=36&q=dream%20theater&limit=6"} logic.js:114 object {collection: array[3], next_href: "https://api.soundcloud.com/tracks?linked_partition…6184b18e16c81&offset=42&q=dream%20theater&limit=6"}
this inconsistent. why?
Comments
Post a Comment