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

Method request

wxapp/nice.js:182–203  ·  view source on GitHub ↗
(apiPath, data = {}, options = {})

Source from the content-addressed store, hash-verified

180 }
181
182 async request(apiPath, data = {}, options = {}) {
183 const payload = this.buildPayload(options.skipToken ? data : { token: this.token, ...data });
184 const res = await axios.post(`${API_BASE}${apiPath}`, encryptPayload(payload), {
185 headers: this.getHeaders(),
186 timeout: 15000,
187 validateStatus: () => true,
188 });
189 const result = res.data;
190 if (res.status !== 200) throw new Error(`HTTP ${res.status}: ${JSON.stringify(result)}`);
191 if (!result || result.flag !== 0) {
192 const message = result?.msg || result?.data?.message || result?.data?.reason || JSON.stringify(result);
193 const err = new Error(message);
194 err.flag = result?.flag;
195 throw err;
196 }
197 if (result?.data?.reason === "unlogin") {
198 const err = new Error("unlogin");
199 err.flag = result.flag;
200 throw err;
201 }
202 return result.data;
203 }
204
205 async getLoginCode() {
206 const { data } = await wechat.getCode(this.openid);

Callers 4

loginByWxCodeMethod · 0.95
getUserMethod · 0.95
getSignLogMethod · 0.95
doSignMethod · 0.95

Calls 4

buildPayloadMethod · 0.95
getHeadersMethod · 0.95
encryptPayloadFunction · 0.85
postMethod · 0.45

Tested by

no test coverage detected