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

Method request

wxapp/fej.js:154–173  ·  view source on GitHub ↗
({ method = "GET", path: apiPath, params = {}, data = {}, skipToken = false })

Source from the content-addressed store, hash-verified

152 }
153
154 async request({ method = "GET", path: apiPath, params = {}, data = {}, skipToken = false }) {
155 const options = {
156 method,
157 url: `${API_BASE}${apiPath.startsWith("/") ? apiPath : `/${apiPath}`}`,
158 headers: this.getHeaders(method === "POST" ? { "Content-Type": "application/json" } : {}),
159 timeout: 15000,
160 validateStatus: () => true,
161 };
162 if (!skipToken) options.params = this.getBaseParams(params);
163 else options.params = params;
164 if (method !== "GET") options.data = data;
165
166 const { data: result, status, headers } = await axios.request(options);
167 if (headers["set-cookie"]) {
168 this.cookie = headers["set-cookie"].map((item) => item.split(";")[0]).join("; ");
169 }
170 if (status !== 200) throw new Error(`HTTP ${status}: ${JSON.stringify(result)}`);
171 if (!result || result.code !== 0) throw new Error(result?.msg || JSON.stringify(result));
172 return result.data;
173 }
174
175 async getLoginCode() {
176 const { data } = await wechat.getCode(this.openid);

Callers 5

loginByWxCodeMethod · 0.95
checkTokenMethod · 0.95
showCheckinPageMethod · 0.95
doCheckinMethod · 0.95
getPointsMethod · 0.95

Calls 2

getHeadersMethod · 0.95
getBaseParamsMethod · 0.95

Tested by

no test coverage detected