/
sphttp.js
71 lines (47 loc) · 1.42 KB
/
sphttp.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/**
* @ngdoc object
* @name ngSharePoint.SPHttp
*
* @description
* SPHttp service is a core ng-SharePoint service that facilitates communication with remote REST api and perform
* common configuration and response process tasks.
*
*/
angular.module('ngSharePoint').service('SPHttp',
['$q', '$http',
function ($q, $http) {
'use strict';
/**
* Makes a GET call to a specified REST api
* *Internal use*
*/
this.get = function(url, params) {
var self = this;
var def = $q.defer();
$http({
url: url,
method: 'GET',
headers: {
"Accept": "application/json; odata=verbose"
}
}).then(function(data) {
var d = utils.parseSPResponse(data);
def.resolve(d);
}, function(data, errorCode, errorMessage) {
var err = utils.parseError({
data: data.config,
errorCode: data.status,
errorMessage: data.statusText
});
def.reject(err);
});
return def.promise;
}; // get
/**
* Makes a POST call to a specified REST api
* *Internal use*
*/
this.post = function(url, params) {
}; // setJSLink
}
]);