Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
var KpccClient;
KpccClient = (function() {
KpccClient.prototype.baseUrl = "http://scpr.org/api/content";
function KpccClient(apiKey) {
this.apiKey = apiKey;
}
KpccClient.prototype.get = function(params) {
if (params == null) {
params = {};
}
return $.ajax({
type: "GET",
url: this.baseUrl,
data: {
query: params.query,
types: params.types,
limit: params.limit,
order: params.order
},
dataType: "json"
});
};
return KpccClient;
})();
client = new KpccClient("someapikey");
jqXHR = client.get({query: "Obama"});
for (_i = 0, _len = jqXHR.responseText.length; _i < _len; _i++) {
obj = jqXHR.responseText[_i];
console.log(obj.headline);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment