MCPcopy Create free account
hub / github.com/apache/struts-examples / _request

Function _request

rest-angular/src/main/webapp/js/services/DataService.js:73–97  ·  view source on GitHub ↗

A generic helper method to execute a HTTP request to the backend

(url, method, model)

Source from the content-addressed store, hash-verified

71
72 /** A generic helper method to execute a HTTP request to the backend */
73 function _request(url, method, model){
74 var def = $q.defer(),
75 req = {
76 method: method,
77 url: url +suffix
78 };
79
80 if(!method) {
81 req.method = 'GET';
82 }
83
84 if(model) {
85 req.data = model;
86 }
87 $http(req).success(function(data) {
88 def.resolve(data);
89 }).error(function(data, code) {
90 def.reject(data);
91 if(data.actionError) {
92 $rootScope.$emit('data-error', { msg: data.actionError });
93 }
94 $log.error(data, code);
95 });
96 return def.promise;
97 }
98 }
99
100})();

Callers 5

getOrdersFunction · 0.85
getOrderFunction · 0.85
addOrderFunction · 0.85
editOrderFunction · 0.85
deleteOrderFunction · 0.85

Calls 1

$httpFunction · 0.50

Tested by

no test coverage detected