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

Method request

wxapp/nissin.js:138–163  ·  view source on GitHub ↗
({ method = "GET", apiPath, data, params, skipToken = false })

Source from the content-addressed store, hash-verified

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

Callers 6

loginByWxCodeMethod · 0.95
getUserMethod · 0.95
getSignInInfoMethod · 0.95
doSignMethod · 0.95
getTaskListMethod · 0.95
enterGameMethod · 0.95

Calls 1

getHeadersMethod · 0.95

Tested by

no test coverage detected