云函数如下
const cloud = require('wx-server-sdk')
cloud.init({
traceUser: true,
env: cloud.DYNAMIC_CURRENT_ENV,
})
const db = cloud.database()
const ngCollection = db.collection('ng')
const _ = db.command
exports.main = async (event) => {
const { type, payload } = event
if (type === 'LIST') {
console.log('123')
return await ngCollection.get()
}
云端测试没问题,能正常返回数据。
本地调试报错: 函数执行失败(耗时 147ms) Error: errCode: -502005 database collection not exists | errMsg: [ResourceNotFound] Db or Table not exist. Please check your request, but if the problem cannot be solved, contact us.;
小程序端报错:errCode: -404011 cloud function execution error | errMsg: cloud.callFunction:fail requestID local_debug_0dd9ba91-74f4-4597-9964-1e6e098511e9, cloud function service error code -1, error message errCode: -502005 database collection not exists | errMsg: [ResourceNotFound] Db or Table not exist. Please check your request, but if the problem cannot be solved, contact us.; ; at cloud.callFunction api;
不知道是什么问题。是 env 吗?