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

Method request

wxapp/mfd.js:181–202  ·  view source on GitHub ↗
({ method = "GET", apiPath, params = {}, data = {} })

Source from the content-addressed store, hash-verified

179 }
180
181 async request({ method = "GET", apiPath, params = {}, data = {} }) {
182 const upperMethod = method.toUpperCase();
183 const options = {
184 method: upperMethod,
185 url: `${API_BASE}${apiPath.startsWith("/") ? apiPath : `/${apiPath}`}`,
186 headers: this.getHeaders(),
187 timeout: 20000,
188 validateStatus: () => true,
189 };
190 if (upperMethod === "GET") options.params = { ...params, _: Date.now() };
191 else {
192 options.params = { _: Date.now() };
193 options.data = data;
194 }
195
196 const { data: result, status } = await axios.request(options);
197 if (status !== 200) throw new Error(`HTTP ${status}: ${JSON.stringify(result)}`);
198 if (!result || (String(result.code) !== "0" && Number(result.code) !== 2)) {
199 throw new Error(result?.msg || result?.message || JSON.stringify(result));
200 }
201 return result;
202 }
203
204 async getLoginCode() {
205 if (!process.env.wx_auth) throw new Error("缺少 wx_auth,无法从 wx_server 获取 code");

Callers 5

getIdentityInfoMethod · 0.95
loginByWxCodeMethod · 0.95
queryMemberByIdMethod · 0.95
getContinuousDaysMethod · 0.95
signInMethod · 0.95

Calls 1

getHeadersMethod · 0.95

Tested by

no test coverage detected