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

Method request

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

Source from the content-addressed store, hash-verified

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