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

Function httpRequest

jlqc.js:512–543  ·  view source on GitHub ↗
(options, method)

Source from the content-addressed store, hash-verified

510 return newoptions
511}
512function httpRequest(options, method) {
513 //options = changeCode(options)
514 typeof (method) === 'undefined' ? ('body' in options ? method = 'post' : method = 'get') : method = method
515 return new Promise((resolve) => {
516 $[method](options, (err, resp, data) => {
517 try {
518 if (err) {
519 console.log(`${method}请求失败`);
520 //console.log(JSON.parse(err));
521 $.logErr(err);
522 //throw new Error(err);
523 //console.log(err);
524 } else {
525 //httpResult = data;
526 //httpResponse = resp;
527 if (data) {
528 data = JSON.parse(data);
529 //console.log(data);
530 resolve(data)
531 } else {
532 console.log(`请求api返回数据为空,请检查自身原因`)
533 }
534 }
535 } catch (e) {
536 //console.log(e, resp);
537 $.logErr(e, resp);
538 } finally {
539 resolve();
540 }
541 })
542 })
543}
544// 等待 X 秒
545function wait(n) { return new Promise(function (resolve) { setTimeout(resolve, n * 1000) }) }
546// 双平台log输出

Callers 10

info_pointMethod · 0.70
task_shareMethod · 0.70
task_signMethod · 0.70
task_create1Method · 0.70
task_create2Method · 0.70
task_commentMethod · 0.70
task_delatMethod · 0.70
task_artlistMethod · 0.70
hitokotoMethod · 0.70
getNoticeFunction · 0.70

Calls 2

logMethod · 0.45
logErrMethod · 0.45

Tested by

no test coverage detected