之前已经调试好了,也能正常发送订阅消息了,现在突然报错"errorCode":1,"errorMessage":"user code exception caught","stackTrace":"Unexpected identifier",重新上传部署也不行,附上代码
const cloud = require('wx-server-sdk')
cloud.init()
const db = cloud.database()
exports.main = async (event, context) => {
const wxContext = cloud.getWXContext()
// const _openid = wxContext.OPENID
try {
const admin = await db.collection('subsceibeMessage');
admin.get({
success: (res) => {
let admins = res.data;
for (let i = 0; i < admins.length; i++) {
const _openid = admins[i]._openid
const result = await cloud.openapi.subscribeMessage.send({
touser: "_openid",
page: 'index',
data: {
thing1: {
value: "通报更新"
},
name2: {
value: "李春"
},
thing3:{
value: "~棒棒哒~"
},
},
templateId: 'PkTIqQ2gEe8Il_k5yOUbaV3AiIqZ3gO2eUh6unWx0wg'
})
console.log("云函数结果",result)
return result
}
}
})
} catch (err) {
console.log("云函数结果",err)
return err
}
}