content/hifi-content/caitlyn/scratch/ionicTabletTest/js/services.js
2022-02-13 22:19:19 +01:00

32 lines
No EOL
767 B
JavaScript

angular.module('app.services', [])
.service('Survey', ['$http', function($http){
var api_url = 'https://sheetsu.com/apis/v1.0/d4dee53ff3d3';
var currentID = 1;
var ret = {
all: function(){
return $http.get(api_url).then(function(resp){
if (resp.data.length > 0) currentID = parseInt(resp.data[resp.data.length-1].id);
return resp.data;
});
},
add: function(data){
currentID++;
data.id = currentID;
return $http.post(api_url, data).then(function(resp){
return resp.data;
});
}
}
ret.all();
return ret;
}]);