-
Notifications
You must be signed in to change notification settings - Fork 54
/
request-config.js
executable file
·54 lines (54 loc) · 1.35 KB
/
request-config.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
'use strict';
var rp = require('request-promise');
var cache = require('./session-cache');
module.exports = (function () {
var sessionCookie = '';
return {
getRequestPromise: function getRequestPromise(queryString, url) {
var options = {
uri: url,
qs: queryString,
headers: {
'User-Agent': 'Request-Promise',
Cookie: sessionCookie
},
json: true,
rejectUnauthorized: false,
requestCert: true
};
return rp(options);
},
setAuthorization: function (authorization) {
sessionCookie = authorization;
},
getAuthorization: function () {
return sessionCookie;
},
postRequestPromise: function postRequestPromise(payload, uri) {
var options = {
method: 'POST',
uri: uri,
headers: {
'User-Agent': 'Request-Promise',
Cookie: sessionCookie,
'content-type': 'application/json'
},
body: payload,
json: true
};
return rp(options);
},
deleteRequestPromise: function deleteRequestPromise(uri) {
var options = {
method: 'DELETE',
headers: {
'User-Agent': 'Request-Promise',
Cookie: sessionCookie
},
uri: uri,
resolveWithFullResponse: true
};
return rp(options);
}
};
})();