MCPcopy Create free account
hub / github.com/smallfawn/QLScriptPublic / api

Method api

wxapp/fhxmh.js:91–107  ·  view source on GitHub ↗
({ method = "GET", path, data, allowFail = false })

Source from the content-addressed store, hash-verified

89 }
90
91 async api({ method = "GET", path, data, allowFail = false }) {
92 const opts = {
93 method,
94 url: `${this.base}${path}`,
95 headers: {
96 Authorization: this.token,
97 locale: "zh_CN",
98 "content-type": "application/json",
99 },
100 };
101 if (method === "GET") opts.params = data || {};
102 else opts.data = data === undefined ? {} : data;
103 const res = await request(opts);
104 const ok = res.status === 200 && ["00000", "000000", "A00002"].includes(String(res.data?.code));
105 if (!ok && !allowFail) throw new Error(`HTTP ${res.status}: ${short(res.data)}`);
106 return res.data;
107 }
108
109 async login() {
110 const code = await getWxCode(APP.appid, this.openid);

Callers 2

queryMethod · 0.95
signMethod · 0.95

Calls 2

requestFunction · 0.70
shortFunction · 0.70

Tested by

no test coverage detected