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

Function getWxCode

wxapp/tclx_lc.js:61–72  ·  view source on GitHub ↗
(appid, openid)

Source from the content-addressed store, hash-verified

59}
60
61async function getWxCode(appid, openid) {
62 if (!WX_AUTH) throw new Error("未配置 wx_auth");
63 const { status, data } = await request({
64 method: "POST",
65 url: `${WX_SERVER_URL}/wx/code`,
66 headers: { auth: WX_AUTH, "content-type": "application/json" },
67 data: { appid, openid },
68 });
69 const code = data?.code || data?.data?.code || data?.phoneCode || data?.data?.phoneCode;
70 if (status !== 200 || !code) throw new Error(`获取code失败 HTTP ${status}: ${short(data)}`);
71 return code;
72}
73
74class Tongcheng {
75 constructor(openid) {

Callers 1

loginMethod · 0.70

Calls 2

requestFunction · 0.70
shortFunction · 0.70

Tested by

no test coverage detected