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

Method request

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

Source from the content-addressed store, hash-verified

161 }
162
163 async request({ method = "GET", path: apiPath, params = {}, data = {}, skipToken = false }) {
164 const options = {
165 method,
166 url: `${API_BASE}${apiPath.startsWith("/") ? apiPath : `/${apiPath}`}`,
167 headers: this.getHeaders(method === "POST" ? { "Content-Type": "application/json" } : {}),
168 timeout: 15000,
169 validateStatus: () => true,
170 };
171 options.params = skipToken ? params : this.getBaseParams(params);
172 if (method !== "GET") options.data = data;
173
174 const { data: result, status, headers } = await axios.request(options);
175 if (headers["set-cookie"]) {
176 this.cookie = headers["set-cookie"].map((item) => item.split(";")[0]).join("; ");
177 }
178 if (status !== 200) throw new Error(`HTTP ${status}: ${JSON.stringify(result)}`);
179 if (!result || result.code !== 0) throw new Error(result?.msg || JSON.stringify(result));
180 return result.data;
181 }
182
183 async getLoginCode() {
184 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