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

Method request

wxapp/sinsin.js:150–168  ·  view source on GitHub ↗
({ method = "GET", apiPath, query = {}, data = {} })

Source from the content-addressed store, hash-verified

148 }
149
150 async request({ method = "GET", apiPath, query = {}, data = {} }) {
151 const options = {
152 method,
153 url: this.buildUrl(apiPath, query),
154 headers: this.getHeaders(method === "POST" ? { "Content-Type": "application/json" } : {}),
155 timeout: 15000,
156 validateStatus: () => true,
157 };
158 if (method !== "GET") options.data = data;
159
160 const { status, data: result } = await axios.request(options);
161 if (status !== 200) throw new Error(`HTTP ${status}: ${typeof result === "string" ? result.slice(0, 200) : JSON.stringify(result)}`);
162 if (!result || result.code !== 0) {
163 const err = new Error(result?.msg || result?.message || JSON.stringify(result));
164 err.code = result?.code;
165 throw err;
166 }
167 return result.data;
168 }
169
170 async getWxCode() {
171 const wxServerUrl = process.env.wx_server_url;

Callers 3

getPointsMethod · 0.95
getCheckinInfoMethod · 0.95
doCheckinMethod · 0.95

Calls 2

buildUrlMethod · 0.95
getHeadersMethod · 0.95

Tested by

no test coverage detected