MCPcopy Index your code
hub / github.com/smallfawn/QLScriptPublic / request

Method request

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

Source from the content-addressed store, hash-verified

129 }
130
131 async request({ method = "GET", apiPath, params = {}, data = {}, skipToken = false }) {
132 const options = {
133 method,
134 url: `${API_BASE}${apiPath}`,
135 headers: this.getHeaders(method === "POST" ? { "Content-Type": "application/json" } : {}),
136 timeout: 15000,
137 validateStatus: () => true,
138 };
139 if (method === "GET") options.params = params;
140 else options.data = data;
141 if (skipToken) delete options.headers.Authorization;
142
143 const { status, data: result } = await axios.request(options);
144 if (status !== 200) throw new Error(`HTTP ${status}: ${JSON.stringify(result)}`);
145 if (!result || result.code !== 0) {
146 const message = result?.msg || result?.message || JSON.stringify(result);
147 const err = new Error(message);
148 err.code = result?.code;
149 throw err;
150 }
151 return result.data;
152 }
153
154 async getLoginCode() {
155 const { data } = await wechat.getCode(this.openid);

Callers 4

loginByWxCodeMethod · 0.95
getUserMethod · 0.95
getSignListMethod · 0.95
doSignMethod · 0.95

Calls 1

getHeadersMethod · 0.95

Tested by

no test coverage detected