收藏
回答

云函数里加入if判断后,调用就返回null,为什么啊?

云函数 去掉 if判断,houseowner给到常量调用正常。加入if判断就出错,求教为什么啊?

个人业余开发一直搜不到原因,身边的程序员也都没接触过云开发。

const aaaRes=await db.collection('whoami').aggregate()

      .match({_id:event.id})

      .lookup({

        from: "user",

        localField: "user",

        foreignField: "_openid",

        as: "userList"

      })   

      .project({

        user:0,

      })

      .end() 

      //判断是不是房主

      if(aaaRes.list[0].owner==wxContext.OPENID){

        const owner=true

      }else{

        const owner=false

      }

      return {  list:aaaRes.list[0],

                houseowner: owner}


回答关注问题邀请回答
收藏

1 个回答

  • Mr.Zhao
    Mr.Zhao
    2020-06-17

    跟云开发没关系。看看云函数日志,报什么错

    owner为什么不定义到if外面?应该是这里报错了

    2020-06-17
    有用 1
    回复 1
    • 小矮子
      小矮子
      2020-06-17
      就是这里,定义在外面就行了!感谢
      2020-06-17
      回复
登录 后发表内容
问题标签