-
Notifications
You must be signed in to change notification settings - Fork 291
Expand file tree
/
Copy path_lib.request.js
More file actions
36 lines (31 loc) · 779 Bytes
/
_lib.request.js
File metadata and controls
36 lines (31 loc) · 779 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
25
26
27
28
29
30
31
32
33
34
35
36
// import axios from '../libs_drpy/axios.min.js';
async function requestHtml(url, options) {
try {
let html = (await req(url, options)).content;
// log(html);
return html
} catch (e) {
log(`requestHtml error:${e.message}`);
return ''
}
}
async function requestJson(url, options) {
try {
let html = (await req(url, options)).content;
return JSON.parse(html)
} catch (e) {
log(`requestJson error:${e.message}`);
return {}
}
}
async function getPublicIp() {
let ip_obj = await requestJson('http://httpbin.org/ip');
// log('ip_obj:',ip_obj);
return ip_obj.origin
}
$.exports = {
requestHtml,
requestJson,
getPublicIp,
// axios // 没法import系统库
}