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

Function getWxCode

wxapp/huazhu.js:81–92  ·  view source on GitHub ↗
(openid)

Source from the content-addressed store, hash-verified

79}
80
81async function getWxCode(openid) {
82 if (!WX_AUTH) throw new Error("未配置 wx_auth,无法从 wx_server 获取 code");
83 const { status, data } = await request({
84 method: "POST",
85 url: `${WX_SERVER_URL}/wx/code`,
86 headers: { auth: WX_AUTH, "Content-Type": "application/json" },
87 data: { appid: MINI_APP_ID, openid },
88 });
89 const code = data?.data?.code || data?.code;
90 if (status !== 200 || !code) throw new Error(`获取 code 失败 HTTP ${status}: ${short(data)}`);
91 return code;
92}
93
94function wxHeaders(sId = "") {
95 return {

Callers 1

loginMethod · 0.70

Calls 2

requestFunction · 0.70
shortFunction · 0.70

Tested by

no test coverage detected