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

Method api

wxapp/skyworth.js:141–154  ·  view source on GitHub ↗
(method, path, data = {}, headers = {})

Source from the content-addressed store, hash-verified

139 }
140
141 async api(method, path, data = {}, headers = {}) {
142 const { status, data: result } = await request({
143 method,
144 url: `${API_BASE}${path}`,
145 params: method.toUpperCase() === "GET" ? data : undefined,
146 data: method.toUpperCase() === "GET" ? undefined : data,
147 headers: {
148 ...(this.token ? { Authorization: `Bearer ${this.token}` } : {}),
149 ...headers,
150 },
151 });
152 if (status !== 200) throw new Error(`${path} HTTP ${status}: ${short(result)}`);
153 return result;
154 }
155
156 assertOk(data, name) {
157 if (Number(data?.code) !== 0) throw new Error(`${name}失败: ${short(data)}`);

Callers 4

loginMethod · 0.95
queryUserMethod · 0.95
queryTasksMethod · 0.95
completeTaskMethod · 0.95

Calls 2

requestFunction · 0.70
shortFunction · 0.70

Tested by

no test coverage detected