Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrequest.js
More file actions
Latest commit
48 lines (45 loc) · 1.02 KB
/
Copy pathrequest.js
File metadata and controls
48 lines (45 loc) · 1.02 KB
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
constrequest=require('requestretry');
const_=require('lodash');
module.exports={
sendRequest(req){
request(req).then((response)=>{
console.log(`Complete: ${JSON.stringify(response)}`);
});
},
get(url,auth){
constreq={
uri: url||'',
json: true,
method: 'GET',
headers: {
'Content-Type': 'application/json',
'Authorization': auth
},
};
constopts={
maxAttempts: 5,
retryDelay: 5000,
retryStrategy: request.RetryStrategies.HTTPOrNetworkError,
};
_.extend(req,opts);
this.sendRequest(req);
},
post(url,auth,data){
constreq={
uri: url||'',
body: JSON.stringify(data),
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': auth
},
};
constopts={
maxAttempts: 5,
retryDelay: 5000,
retryStrategy: request.RetryStrategies.HTTPOrNetworkError,
};
_.extend(req,opts);
this.sendRequest(req);
},
}