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

Method request

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

Source from the content-addressed store, hash-verified

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

Callers 5

authorizeMethod · 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