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

Method request

wxapp/haitian.js:193–211  ·  view source on GitHub ↗
(pathname, { method = "GET", params, data, auth = true, isJson = false, base = API_BASE } = {})

Source from the content-addressed store, hash-verified

191 }
192
193 async request(pathname, { method = "GET", params, data, auth = true, isJson = false, base = API_BASE } = {}) {
194 const options = {
195 method,
196 url: `${base}${pathname}`,
197 params,
198 headers: this.headers({}, auth, isJson),
199 timeout: 20000,
200 validateStatus: () => true,
201 };
202 if (data !== undefined) options.data = isJson ? data : new URLSearchParams(data).toString();
203
204 const { data: result, status } = await axios.request(options);
205 if (status === 401 || status === 403) throw new Error(`HTTP ${status}: ${result?.message || JSON.stringify(result)}`);
206 if (status < 200 || status >= 300) throw new Error(`HTTP ${status}: ${JSON.stringify(result)}`);
207 if (result && typeof result === "object" && result.code && !["200", "0"].includes(String(result.code))) {
208 throw new Error(`${result.code} ${result.message || result.msg || JSON.stringify(result)}`.trim());
209 }
210 return result;
211 }
212
213 async getOperateData() {
214 if (!process.env.wx_auth) throw new Error("缺少 wx_auth,无法从 wx_server 获取登录数据");

Callers 14

getArticleIdsMethod · 0.95
loginByWxCodeMethod · 0.95
loginCommunityTokenMethod · 0.95
checkTokenMethod · 0.95
getUserInfoMethod · 0.95
getSignActivityMethod · 0.95
signInMethod · 0.95
task_1Method · 0.95
task_2Method · 0.95
doLotteryMethod · 0.95
getLotteryTaskListMethod · 0.95
lotteryTaskBrowserMethod · 0.95

Calls 1

headersMethod · 0.95

Tested by

no test coverage detected