能嵌套调用云函数吗?
// 云函数入口文件
const cloud = require('wx-server-sdk')
cloud.init()
// 云函数入口函数
exports.main = async (event, context) => {
const wxContext = cloud.getWXContext()
return await cloud.callFunction({
name: 'selectUserByOpenid',
data: {_openid:wxContext.OPENID}
}).then(res =>{
if(res.result){
return await cloud.callFunction({
name:'saveUserInfo',
data:{userInfo:event.userInfo,
_openid: wxContext.OPENID}
}).then(res=>{
return 1
})
}
else{
return 2
}
})
}
1 回复
// 云函数入口文件
const cloud = require('wx-server-sdk')
cloud.init()
// 云函数入口函数
exports.main = async (event, context) => {
const wxContext = cloud.getWXContext()
const res = await cloud.callFunction({
name: 'selectUserByOpenid',
data: { _openid: wxContext.OPENID }
})
if (res.result) {
const res1 = await cloud.callFunction({
name: 'saveUserInfo',
data: { userInfo: event.userInfo,
_openid: wxContext.OPENID }
})
return res1
}
return 2
}