' Use strict ';
Require (' native-promise-only '); Module.exports = {wrapperrequest:function (type, URL, data, ishideloading) {var type = arguments[0], url =
ARGUMENTS[1], data, ishideloading;
if (arguments[2] && typeof arguments[2] = = ' Boolean ') {ishideloading = arguments[2];
else {data = arguments[2];
ishideloading = arguments[3];
var loading = new Loadingservice ();
if (!ishideloading) {loading.show (); var httpip = Global.
Env.remotehost;
Httpip = Httpip + '/api/';
var aurl = httpip + URL;
var self = this; var promise = new Promise (function (resolve, reject) {var httpconfig = {Type:type, content
Type: ' Application/json ', Url:aurl, DataType: ' JSON '};
Httpconfig.headers = {' X-auth-token ': ' xxxxxxxx '};
if (data) { Httpconfig.data = data;
} httpconfig.success = function (data, textstatus, request) {resolve (data);
}; Httpconfig.error = function (Error) {if (Error.status = = 401) {} else {Rej
ECT (Json.parse (error.response));
}
};
$.ajax (Httpconfig);
});
return promise;
}, Get:function (URL, data, ishideloading) {return this.wrapperrequest (' Get ', url, data, ishideloading);
}, Put:function (URL, data, ishideloading) {data = json.stringify (data);
Return this.wrapperrequest (' Put ', url, data, ishideloading);
}, Post:function (URL, data, ishideloading) {data = json.stringify (data);
Return this.wrapperrequest (' POST ', url, data, ishideloading);
}, Delete:function (URL, ishideloading) {return this.wrapperrequest (' delete ', url, ishideloading);
}
}; Using the Var HttpservIce = require (' Http-service ');
Gethttpdata:function (ID) {return httpservice.get (' xxx/' +id); },