Created
January 12, 2014 15:12
-
-
Save gintsgints/8385837 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
/* results are returned as a promise */ | |
promiseThen = function (httpPromise, successcb, errorcb) { | |
return httpPromise.then(function (response) { | |
(successcb || angular.noop)(response.data); | |
return response.data; | |
}, function (response) { | |
(errorcb || angular.noop)(response.data); | |
return response.data; | |
}); | |
}; | |
post: function (path, data, successcb, errorcb) { | |
path = config.server + path; | |
var reqConfig = {url: path, data: data, method: 'POST'}; | |
return promiseThen($http(angular.extend(reqConfig, config)), successcb, errorcb); | |
}, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment