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

Method request

wxapp/jingyoujia.js:146–164  ·  view source on GitHub ↗
({ method = "GET", apiPath, params = {}, data = {}, notAuth = false })

Source from the content-addressed store, hash-verified

144 }
145
146 async request({ method = "GET", apiPath, params = {}, data = {}, notAuth = false }) {
147 const upperMethod = method.toUpperCase();
148 const options = {
149 method: upperMethod,
150 url: `${API_BASE}${apiPath.startsWith("/") ? apiPath : `/${apiPath}`}`,
151 headers: this.getHeaders(notAuth ? { Authorization: "none" } : {}),
152 timeout: 20000,
153 validateStatus: () => true,
154 };
155 if (upperMethod === "GET") options.params = params;
156 else options.data = data;
157
158 const { data: result, status } = await axios.request(options);
159 if (status !== 200) throw new Error(`HTTP ${status}: ${JSON.stringify(result)}`);
160 if (!result || (Number(result.code) !== 200 && String(result.code) !== "200")) {
161 throw new Error(result?.msg || result?.message || JSON.stringify(result));
162 }
163 return result.data;
164 }
165
166 async getLoginCode() {
167 const { data } = await wechat.getCode(this.account);

Callers 8

loginByWxCodeMethod · 0.95
checkTokenMethod · 0.95
getCustomerDetailsMethod · 0.95
getIntegralMethod · 0.95
findCheckTaskMethod · 0.95
queryRecordMethod · 0.95
signInMethod · 0.95
finishTaskMethod · 0.95

Calls 1

getHeadersMethod · 0.95

Tested by

no test coverage detected