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

Method request

wxapp/wb.js:186–206  ·  view source on GitHub ↗
(apiPath, data = {}, method = "GET", options = {})

Source from the content-addressed store, hash-verified

184 }
185
186 async request(apiPath, data = {}, method = "GET", options = {}) {
187 const payload = options.enterpriseNo ? { ...data } : { enterpriseNo: ENTERPRISE_NO, ...data };
188 const requestOptions = {
189 method,
190 url: `${API_BASE}/${apiPath}`,
191 headers: this.getHeaders(method, apiPath, payload),
192 timeout: 20000,
193 validateStatus: () => true,
194 };
195 if (method.toUpperCase() === "GET") requestOptions.params = payload;
196 else requestOptions.data = payload;
197
198 const { status, data: result } = await axios.request(requestOptions);
199 if (status !== 200) throw new Error(`HTTP ${status}: ${JSON.stringify(result)}`);
200 if (!options.allowAnyCode && result?.code !== 200) {
201 const err = new Error(result?.message || JSON.stringify(result));
202 err.code = result?.code;
203 throw err;
204 }
205 return result;
206 }
207
208 async getLoginCode() {
209 const { data } = await wechat.getCode(this.openid);

Callers 15

loginByWxCodeMethod · 0.95
getUserMethod · 0.95
signInMethod · 0.95
getTaskListMethod · 0.95
setTaskOkMethod · 0.95
completeTaskMethod · 0.95
getQrUuidFunction · 0.45
qrcodeAuthFunction · 0.45
loginByCodeFunction · 0.45
createAuthFunction · 0.45
doLotteryFunction · 0.45
requestFunction · 0.45

Calls 1

getHeadersMethod · 0.95

Tested by

no test coverage detected