MCPcopy Index your code
hub / github.com/smallfawn/QLScriptPublic / httpRequest

Function httpRequest

backup/sysxc.js:276–305  ·  view source on GitHub ↗
(options, method)

Source from the content-addressed store, hash-verified

274}
275/////////////////////////////////////////////////////////////////////////////////////
276function httpRequest(options, method) {
277 typeof (method) === 'undefined' ? ('body' in options ? method = 'post' : method = 'get') : method = method
278 return new Promise((resolve) => {
279 $[method](options, (err, resp, data) => {
280 try {
281 if (err) {
282 console.log(`${method}请求失败`);
283 $.logErr(err);
284 //throw new Error(err);
285 //console.log(err);
286 } else {
287 //httpResult = data;
288 //httpResponse = resp;
289 if (data) {
290 //console.log(data);
291 typeof JSON.parse(data) == 'object' ? data = JSON.parse(data) : data = data
292 resolve(data)
293 } else {
294 console.log(`请求api返回数据为空,请检查自身原因`)
295 }
296 }
297 } catch (e) {
298 //console.log(e, resp);
299 $.logErr(e, resp);
300 } finally {
301 resolve();
302 }
303 })
304 })
305}
306/**
307 * 时间戳 13位
308 */

Callers 6

getVcodeMethod · 0.70
checkVcodeMethod · 0.70
SignInMethod · 0.70
noticeFunction · 0.70
ocrFunction · 0.70
hitokotoFunction · 0.70

Calls 2

logMethod · 0.45
logErrMethod · 0.45

Tested by

no test coverage detected