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

Function httpRequest

gqftbz.js:672–701  ·  view source on GitHub ↗
(options, method)

Source from the content-addressed store, hash-verified

670}
671/////////////////////////////////////////////////////////////////////////////////////
672function httpRequest(options, method) {
673 method = options.method
674 ? options.method.toLowerCase()
675 : options.body
676 ? "post"
677 : "get";
678 return new Promise((resolve) => {
679 $[method](options, (err, resp, data) => {
680 try {
681 if (err) {
682 console.log(`${method}请求失败`);
683 $.logErr(err);
684 } else {
685 if (data) {
686 typeof JSON.parse(data) == "object"
687 ? (data = JSON.parse(data))
688 : (data = data);
689 resolve(data);
690 } else {
691 console.log(`请求api返回数据为空,请检查自身原因`);
692 }
693 }
694 } catch (e) {
695 $.logErr(e, resp);
696 } finally {
697 resolve();
698 }
699 });
700 });
701}
702/**
703 * 判断版本号是否小于 V2.15.0 小于返回true
704 * @param {*} version

Callers 9

user_infoMethod · 0.70
task_signinMethod · 0.70
task_readMethod · 0.70
task_likeMethod · 0.70
task_shareMethod · 0.70
art_listMethod · 0.70
refresh_tokenMethod · 0.70
getNoticeFunction · 0.70
hitokotoFunction · 0.70

Calls 2

logMethod · 0.45
logErrMethod · 0.45

Tested by

no test coverage detected