云函数A主要代码片段如下:
exports.main = async (event, context) => { const wxContext = cloud.getWXContext(); return await cloud.callFunction({ name: 'B' , data: { openId: wxContext.OPENID } }).then(res => { if (res.result.data.length) { return { appId: wxContext.APPID, openId: wxContext.OPENID, env: wxContext.ENV, data: res.result.data }; } else { console.log( '调newUser前' ) await cloud.callFunction({ name: 'C' , data: { openId: wxContext.OPENID } }).then(res => {
}); } }); } |
云函数A的日志报错如下图:
弱弱的问一句 await 还能再 .then ? 是不是自己写得太奇怪了呢
exports.main = async (event, context) => {
const wxContext = cloud.getWXContext();
var res = await cloud.callFunction({
name: 'B',
data: {
openId: wxContext.OPENID
}
})
if (res.result.data.length) {
return {
appId: wxContext.APPID,
openId: wxContext.OPENID,
env: wxContext.ENV,
data: res.result.data
};
} else {
console.log('调newUser前')
res = await cloud.callFunction({
name: 'C',
data: {
openId: wxContext.OPENID
}
})
console.log('newUser', res.result.data)
return res
}
}