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

Method request

wxapp/casetify.js:153–172  ·  view source on GitHub ↗
(method, apiPath, data = {}, options = {})

Source from the content-addressed store, hash-verified

151 }
152
153 async request(method, apiPath, data = {}, options = {}) {
154 const requestOptions = {
155 method,
156 url: `${API_BASE}/${apiPath}`,
157 headers: this.getHeaders(options.auth),
158 timeout: 20000,
159 validateStatus: () => true,
160 };
161 if (method === "GET") requestOptions.params = data;
162 else requestOptions.data = data;
163
164 const { status, data: result } = await axios.request(requestOptions);
165 if (status !== 200) throw new Error(`HTTP ${status}: ${JSON.stringify(result)}`);
166 if (!options.allowAnyCode && result?.resultCode !== "1") {
167 const err = new Error(result?.msg || JSON.stringify(result));
168 err.resultCode = result?.resultCode;
169 throw err;
170 }
171 return result;
172 }
173
174 async getLoginCode() {
175 const { data } = await wechat.getCode(this.openid);

Callers 4

loginByWxCodeMethod · 0.95
getCampaignIdMethod · 0.95
getSignInfoMethod · 0.95
doSignMethod · 0.95

Calls 1

getHeadersMethod · 0.95

Tested by

no test coverage detected