最开始编译是 reqData 没找到,我改成了 let dataBody = requestData,这个错误没有了,现在是这个错误
WASubContext.js?t=wechat&s=1644490119266&v=2.22.0:2 Unhandled promise rejection Error: cloud.callFunction:fail Error: errCode: -504002 functions execute fail | errMsg: TypeError: Cannot read property 'prepay_id' of undefined
at :47893/var/user/index.js:49
以下是我的源码:
xmlreader.read(body, res =>
{
let prepay_id = res.xml.prepay_id.text()
let timeStamp = Date.parse(new Date()).toString()
//是字符串拼接的写法 let str =
appId=${appid}&nonceStr=${random}&package=prepay_id=${prepay_id}&signType=MD5&timeStamp=${timeStamp}&key=Chenhui9304Swtui985nJHyfnvffdEpV`
let paySign = crypto.createHash('md5').update(str).digest('hex')
烦请指教,谢谢