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

Method request

wxapp/gyjj.js:157–176  ·  view source on GitHub ↗
(pathname, { method = "GET", data, params, auth = true, headers = {} } = {})

Source from the content-addressed store, hash-verified

155 }
156
157 async request(pathname, { method = "GET", data, params, auth = true, headers = {} } = {}) {
158 const options = {
159 method,
160 url: `${API_BASE}${pathname}`,
161 params,
162 data,
163 headers: auth ? this.headers(headers) : {
164 "content-Type": "application/json",
165 "User-Agent": defaultUserAgent,
166 Referer: `https://servicewechat.com/${MINI_APP_ID}/${PAGE_VERSION}/page-frame.html`,
167 ...headers,
168 },
169 timeout: 20000,
170 validateStatus: () => true,
171 };
172 const { data: result, status } = await axios.request(options);
173 if (status !== 200) throw new Error(`HTTP ${status}: ${JSON.stringify(result)}`);
174 if (Number(result?.code) !== 0) throw new Error(`${result?.code ?? ""} ${result?.message || JSON.stringify(result)}`.trim());
175 return result;
176 }
177
178 async getOperateData() {
179 if (!process.env.wx_auth) throw new Error("缺少 wx_auth,无法从 wx_server 获取登录数据");

Callers 5

loginByWxCodeMethod · 0.95
checkTokenMethod · 0.95
signMethod · 0.95
accountMethod · 0.95
getNoticeFunction · 0.45

Calls 1

headersMethod · 0.95

Tested by

no test coverage detected