云函数doc.get一直报错,求帮忙看看问题在哪?
发布于 5 年前 作者 ghe 8677 次浏览 来自 问答

本地调用没有问题,改成云函数一直报错,求大佬帮忙看看问题在哪,谢谢.

onLoad: function (options{
    console.log("options.id",options.id)
    wx.cloud.init()
    wx.cloud.callFunction({
      // 要调用的云函数名称
      name'getHtInfo',
      data: {
        id: options.id,
      }
    }).then(res => {
      console.log(res)
    }).catch(err => {
      console.log(err)
    })
  }

// 云函数入口文件

const cloud = require('wx-server-sdk')

cloud.init()
const db = wx.cloud.database()
const bqj_dayHTs = db.collection('bqj_dayHT')

// 云函数入口函数
exports.main = async (event, context) => {
  try {
    return await bqj_dayHTs.doc(event.id).get()
  } catch(e) {
    console.error(e)
  }
}
1 回复
const db = wx.cloud.database()云函数里面没有 wx.
回到顶部