Skip to content

Instantly share code, notes, and snippets.

@webhat
Created June 6, 2013 12:34
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save webhat/5721162 to your computer and use it in GitHub Desktop.
Save webhat/5721162 to your computer and use it in GitHub Desktop.
Keen.IO Resource Factory with Service Model
'use strict';
angular.module('keeniolab', ['ngResource']).
factory('KeenIO',function ($resource) {
var KeenIO = $resource('https://api.keen.io/3.0/projects/513a76812975164a4a000002/queries/:type',
{
api_key: 'api-key',
event_collection: 'read',
timezone: 7200
}, {
update: { method: 'PUT' }
}
);
return KeenIO;
}).service('KeenModel', function (KeenIO) {
var KeenSession = function () {
this.data = {};
};
KeenSession.prototype.fetch = function (query) {
var self = this;
KeenIO.get(query, function (result) {
//console.log("called get");
self.data = result;
//console.log(result.result);
});
};
return new KeenSession();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment