Skip to content

Instantly share code, notes, and snippets.

@acwio
Created July 2, 2015 17:40
Show Gist options
  • Save acwio/796ea15bf933dd5b1ff0 to your computer and use it in GitHub Desktop.
Save acwio/796ea15bf933dd5b1ff0 to your computer and use it in GitHub Desktop.
Simple Panoptes API Consumption Example
sendAuthentication = function (xhr) {
xhr.setRequestHeader('Accept', "application/vnd.api+json; version=1");
};
SubjectModel = Backbone.Model.extend({
initialize:function(opts) {
console.log("init subject : "+opts.id);
}
});
Subjects = Backbone.Collection.extend({
model: SubjectModel,
sync: function(method, model, options) {
var params = _.extend({
type: 'GET',
dataType: 'jsonp',
url: model.url(),
processData: false
}, options);
return $.ajax(params);
},
parse: function(response) {
console.log(response);
return response;
},
url: function() {
return "https://panoptes-staging.zooniverse.org/api/projects/183?display_name=AncientTextualLives&approved=true&beta=true&live=true";
}
});
// Create the Collection
s=new Subjects();
// Fetch
s.fetch({
contentType: "application/json",
beforeSend: sendAuthentication
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment