Created
August 6, 2015 14:30
-
-
Save Crisfole/e3165aa4014882e10b7d to your computer and use it in GitHub Desktop.
Fetch All Active Rollbar Items
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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