forked from csxiaoyaojianxian/JavaScriptStudy
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutil.js
More file actions
24 lines (23 loc) · 568 Bytes
/
util.js
File metadata and controls
24 lines (23 loc) · 568 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
const request = require('request');
module.exports.get = function (url, opt = {}) {
return new Promise((r, j) => {
request.get(url, opt, (err, res, body) => {
if (err) {
j(err);
return;
}
r(body);
});
});
};
module.exports.post = function (url, opt = {}) {
return new Promise((r, j) => {
request.post(url, opt, (err, res, body) => {
if (err) {
j(err);
return;
}
r(body);
});
});
};