(method, urlPath, { token = "", data = null, params = null, custom = {} } = {})
| 117 | } |
| 118 | |
| 119 | async function request(method, urlPath, { token = "", data = null, params = null, custom = {} } = {}) { |
| 120 | const res = await axios({ |
| 121 | method, |
| 122 | url: `${API_BASE}${urlPath}`, |
| 123 | data, |
| 124 | params, |
| 125 | timeout: 30000, |
| 126 | validateStatus: () => true, |
| 127 | headers: { |
| 128 | Accept: "*/*", |
| 129 | "Content-Type": "application/json", |
| 130 | "User-Agent": "Mozilla/5.0 MicroMessenger MiniProgramEnv/Windows", |
| 131 | Referer: `https://servicewechat.com/${MINI_APP_ID}/${PACKAGE_VERSION}/page-frame.html`, |
| 132 | ...(token ? { Authorization: `Bearer ${token}` } : {}), |
| 133 | }, |
| 134 | ...custom, |
| 135 | }); |
| 136 | return { |
| 137 | status: res.status, |
| 138 | data: res.data, |
| 139 | text: typeof res.data === "string" ? res.data : JSON.stringify(res.data), |
| 140 | }; |
| 141 | } |
| 142 | |
| 143 | class Task { |
| 144 | constructor(raw) { |
no outgoing calls
no test coverage detected