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

Method mobilePost

wxapp/qiaqia.js:210–233  ·  view source on GitHub ↗
(apiPath, data = {})

Source from the content-addressed store, hash-verified

208 }
209
210 async mobilePost(apiPath, data = {}) {
211 if (!this.session.sessionId) throw new Error("缺少SESSION");
212 const res = await axios.post(`${MOBILE_BASE}${apiPath}`, formBody({
213 ...(data || {}),
214 userId: USER_ID,
215 }), {
216 headers: this.commonHeaders({
217 Cookie: `SESSION=${this.session.sessionId}`,
218 Authorization: this.session.token || "",
219 }),
220 timeout: 20000,
221 validateStatus: () => true,
222 });
223
224 const newSession = getSessionId(res.headers);
225 if (newSession) this.session.sessionId = newSession;
226
227 if (res.status !== 200) throw new Error(`HTTP ${res.status}`);
228 if (String(res.data?.status) === "-2") throw new Error("登录态失效(-2)");
229 if (String(res.data?.status) !== "0") {
230 throw new Error(res.data?.msg || `接口异常: ${res.data?.status || "unknown"}`);
231 }
232 return res.data;
233 }
234
235 async checkSession() {
236 try {

Callers 4

checkSessionMethod · 0.95
getSignListMethod · 0.95
getSignConfigMethod · 0.95
doSignMethod · 0.95

Calls 4

commonHeadersMethod · 0.95
getSessionIdFunction · 0.85
formBodyFunction · 0.70
postMethod · 0.45

Tested by

no test coverage detected