(openid, appid)
| 197 | } |
| 198 | |
| 199 | async function wxServerCode(openid, appid) { |
| 200 | const { data } = await axios.post( |
| 201 | `${wechat.serverUrl}/wx/code`, |
| 202 | { appid, openid }, |
| 203 | { |
| 204 | headers: { auth: wechat.auth }, |
| 205 | timeout: 30000, |
| 206 | validateStatus: () => true, |
| 207 | } |
| 208 | ); |
| 209 | if (!data?.status) throw new Error(data?.message || "wx_server 获取 code 失败"); |
| 210 | const code = data.data?.code || data.code; |
| 211 | if (!code) throw new Error(`wx_server 未返回 code: ${JSON.stringify(data)}`); |
| 212 | return code; |
| 213 | } |
| 214 | |
| 215 | async function accountRequest(method, urlPath, { data = null, cookies = {}, secret = "" } = {}) { |
| 216 | const url = `${ACCOUNT_BASE}${urlPath}`; |
no test coverage detected