-
Notifications
You must be signed in to change notification settings - Fork 0
/
listItem.js
66 lines (63 loc) · 2.08 KB
/
listItem.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
const axios = require('axios');
const utilities = require('./utilities');
exports.createListItemMe = function(body, IdToken, cognito_client_id, cognito_pool_id){
return new Promise(function(resolve, reject){
url =
process.env.LISTING_SERVICE +
"/lists/" +
body.ListId +
"/listItems/me";
var headers = utilities.createHeaders(IdToken, cognito_client_id, cognito_pool_id);
var options = {
url: url,
method: 'POST',
headers: headers,
data: body
};
axios(options).then(function(result){
resolve(result.data);
}).catch(function(err){
reject(utilities.processAxiosError(err));
});
});
}
exports.getListItemsMe = function(ListId, IdToken, query, cognito_client_id, cognito_pool_id){
return new Promise(function(resolve, reject){
var url =
process.env.LISTING_SERVICE +
"/lists/" +
ListId +
"/listItems/me";
if (query) url += "?" + query;
var headers = utilities.createHeaders(IdToken, cognito_client_id, cognito_pool_id);
var options = {
url: url,
method: 'GET',
headers: headers
};
axios(options).then(function(result){
resolve(result.data);
}).catch(function(err){
reject(utilities.processAxiosError(err));
});
});
}
exports.deleteListItemMe = function(ListItemId, IdToken, cognito_client_id, cognito_pool_id){
return new Promise(function(resolve, reject){
var url =
process.env.LISTING_SERVICE +
"/listItems/"+
ListItemId;
var headers = utilities.createHeaders(IdToken, cognito_client_id, cognito_pool_id);
var options = {
url: url,
method: "DELETE",
headers: headers
};
axios(options).then(function(result){
resolve(result.data);
}).catch(function(err){
reject(utilities.processAxiosError(err));
});
});
}