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

Function apiRequest

wxapp/airui.js:96–116  ·  view source on GitHub ↗
(method, urlPath, { token = "", params = null } = {})

Source from the content-addressed store, hash-verified

94}
95
96async function apiRequest(method, urlPath, { token = "", params = null } = {}) {
97 const timestamp = String(Date.now());
98 const sign = makeSign(urlPath, method, params, timestamp, token);
99 const res = await axios({
100 method,
101 url: `${API_BASE}${urlPath}`,
102 data: method === "POST" ? params : undefined,
103 params: method === "GET" ? params : undefined,
104 timeout: 15000,
105 validateStatus: () => true,
106 headers: {
107 token,
108 sign,
109 timestamp,
110 "Content-Type": "application/json",
111 "User-Agent": "Mozilla/5.0 MicroMessenger MiniProgramEnv/Windows",
112 Referer: `https://servicewechat.com/${MINI_APP_ID}/127/page-frame.html`,
113 },
114 });
115 return res.data;
116}
117
118function assertOk(res, action) {
119 if (!res || Number(res.code) !== 1) {

Callers 2

loginMethod · 0.85
requestWithReloginMethod · 0.85

Calls 1

makeSignFunction · 0.70

Tested by

no test coverage detected