Skip to content

Instantly share code, notes, and snippets.

@Crisfole
Created August 6, 2015 14:30
Show Gist options
  • Save Crisfole/e3165aa4014882e10b7d to your computer and use it in GitHub Desktop.
Save Crisfole/e3165aa4014882e10b7d to your computer and use it in GitHub Desktop.
Fetch All Active Rollbar Items
var accessToken = "READ_ACCESS_TOKEN";
function fetchPage(accessToken, cb, page) {
if (page == null) {
page = 1;
}
var url = "https://api.rollbar.com/api/1/items/?access_token={0}&page={1}&status=active",
items = [];
$.ajax({
dataType: "json",
url: url.replace("{0}", accessToken).replace("{1}", page),
success: function(results) {
items.push.apply(items, results.result.items);
if (results.length == 20) {
fetchPage(accessToken, cb, page+1);
}
else {
cb(items);
}
},
error: function() {
cb(items);
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment