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

Method request

wxapp/parkson.js:140–160  ·  view source on GitHub ↗
({ method = "POST", apiPath, params = {}, data = {}, skipToken = false })

Source from the content-addressed store, hash-verified

138 }
139
140 async request({ method = "POST", apiPath, params = {}, data = {}, skipToken = false }) {
141 const options = {
142 method,
143 url: `${API_BASE}${apiPath}`,
144 headers: this.getHeaders(method === "POST" ? { "Content-Type": "application/json" } : {}),
145 timeout: 15000,
146 validateStatus: () => true,
147 };
148 if (method === "GET") options.params = params;
149 else options.data = data;
150 if (skipToken) delete options.headers.Authorization;
151
152 const { status, data: result } = await axios.request(options);
153 if (status !== 200) throw new Error(`HTTP ${status}: ${JSON.stringify(result)}`);
154 if (result && typeof result === "object" && result.error !== undefined && result.error !== 0) {
155 const err = new Error(result.errorMsg || result.msg || JSON.stringify(result));
156 err.code = result.error;
157 throw err;
158 }
159 return result?.data ?? result;
160 }
161
162 async getLoginCode() {
163 const { data } = await wechat.getCode(this.openid);

Callers 5

loginByWxCodeMethod · 0.95
getUserInfoMethod · 0.95
getPointsInfoMethod · 0.95
getSignListMethod · 0.95
doSignMethod · 0.95

Calls 1

getHeadersMethod · 0.95

Tested by

no test coverage detected