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

Method request

wxapp/feihe.js:156–172  ·  view source on GitHub ↗
({ method = "GET", apiPath, query = {}, data = null, token = this.token, allowFail = false })

Source from the content-addressed store, hash-verified

154 }
155
156 async request({ method = "GET", apiPath, query = {}, data = null, token = this.token, allowFail = false }) {
157 const options = {
158 method,
159 url: buildUrl(apiPath, query),
160 headers: buildSignedHeaders({ data: method === "GET" ? null : data, token }),
161 timeout: 15000,
162 validateStatus: () => true,
163 };
164 if (method !== "GET") options.data = data || {};
165
166 const { status, data: result } = await axios.request(options);
167 const ok = status === 200 && String(result?.code) === "200";
168 if (!ok && !allowFail) {
169 throw new Error(`HTTP ${status} ${JSON.stringify(result)}`);
170 }
171 return result;
172 }
173
174 async getWxCode() {
175 const wxServerUrl = process.env.wx_server_url;

Callers 4

loginByCodeMethod · 0.95
checkTokenMethod · 0.95
getIndexInfoMethod · 0.95
signInMethod · 0.95

Calls 2

buildUrlFunction · 0.85
buildSignedHeadersFunction · 0.85

Tested by

no test coverage detected