MCPcopy Index your code
hub / github.com/smallfawn/QLScriptPublic / request

Method request

wxapp/jyxe.js:126–144  ·  view source on GitHub ↗
(apiPath, data = {}, options = {})

Source from the content-addressed store, hash-verified

124 }
125
126 async request(apiPath, data = {}, options = {}) {
127 const token = options.noauth ? GUEST_TOKEN : (this.session.token || GUEST_TOKEN);
128 const res = await axios.post(`${API_BASE}${apiPath}`, formBody({
129 ...(data || {}),
130 token,
131 }), {
132 headers: this.headers(),
133 timeout: 20000,
134 validateStatus: () => true,
135 });
136
137 if (res.status !== 200) throw new Error(`HTTP ${res.status}`);
138 if (Number(res.data?.code) !== 1000) {
139 const error = new Error(res.data?.msg || `接口错误: ${res.data?.code || "unknown"}`);
140 error.data = res.data;
141 throw error;
142 }
143 return res.data;
144 }
145
146 async getLoginCode() {
147 const { data } = await wechat.getCode(this.openid);

Callers 3

loginByWxCodeMethod · 0.95
checkTokenMethod · 0.95
doSignMethod · 0.95

Calls 3

headersMethod · 0.95
formBodyFunction · 0.70
postMethod · 0.45

Tested by

no test coverage detected