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

Method request

wxapp/ykb_all.js:296–326  ·  view source on GitHub ↗
({ method = "GET", apiPath, params = {}, data = {}, skipToken = false })

Source from the content-addressed store, hash-verified

294 }
295
296 async request({ method = "GET", apiPath, params = {}, data = {}, skipToken = false }) {
297 const options = {
298 method,
299 url: `${this.app.apiBase}${apiPath.startsWith("/") ? apiPath : `/${apiPath}`}`,
300 headers: this.headers(),
301 timeout: 20000,
302 validateStatus: () => true,
303 };
304 if (skipToken) delete options.headers.Authorization;
305 if (method === "GET") options.params = params;
306 else options.data = data;
307
308 const { data: result, status } = await axios.request(options);
309 if (status !== 200) throw new Error(`HTTP ${status}: ${JSON.stringify(result)}`);
310
311 const responseStatus = result && result.ResponseStatus;
312 if (responseStatus) {
313 const code = Number(responseStatus.ErrorCode);
314 if (code !== 0) {
315 const err = new Error(`${responseStatus.Message || JSON.stringify(result)}(${responseStatus.ErrorCode})`);
316 err.raw = result;
317 throw err;
318 }
319 return result.Data;
320 }
321
322 if (typeof result?.code !== "undefined" && Number(result.code) !== 0 && Number(result.code) !== 200) {
323 throw new Error(result.msg || result.message || JSON.stringify(result));
324 }
325 return result?.Data ?? result?.data ?? result;
326 }
327
328 async run() {
329 const cached = this.getCachedToken();

Callers 9

checkTokenMethod · 0.95
loginMethod · 0.95
getMemberInfoMethod · 0.95
getAssetsMethod · 0.95
tryMemberCheckInMethod · 0.95
getTaskListMethod · 0.95
getTaskDetailMethod · 0.95
receiveTaskMethod · 0.95
handleTaskMethod · 0.95

Calls 1

headersMethod · 0.95

Tested by

no test coverage detected