收藏
回答

云开发获取打印员后不能之家查询数据?

// 云函数入口文件
const cloud = require('wx-server-sdk')
//DYNAMIC_CURRENT_ENV
cloud.init({
  env: cloud.DYNAMIC_CURRENT_ENV
})
const db=cloud.database()
const command=db.command
 
// 云函数入口函数
exports.main = async(event, context) => {
  const wxContext = cloud.getWXContext()
  const result = {}
 
  const printerResult = await cloud.openapi.logistics.getPrinter({})
 
  if (printerResult.count == 0) {
 
    result.code = 201
    result.msg = "暂无打印员"
    return result
 
  }
 
  const openids = printerResult.openid
  const userList = await db.collection("user").where(
    {
      _openid: command.in(openids)
    }
  ).get()
  result.code = 200
  result.data = userList.data
  return result
}

错误信息:

Error: errCode: -404011 cloud function execution error | errMsg: cloud.callFunction:fail requestID 6bb4549a-1676-11ea-9dd1-52540047de0f, cloud function service error code -504002, error message errCode: -501001 resource system error | errMsg: [request id:425765127]envname field not exsit in url;
Error: errCode: -501001 resource system error | errMsg: [request id:425765127]envname field not exsit in url;
    at new CloudSDKError (/var/user/node_modules/wx-server-sdk/index.js:6398:28)
    at Object.returnAsCloudSDKError (/var/user/node_modules/wx-server-sdk/index.js:6450:16)
    at Object.checkError (/var/user/node_modules/wx-server-sdk/index.js:1680:23)
    at Query.<anonymous> (/var/user/node_modules/wx-server-sdk/index.js:1746:41)
    at step (/var/user/node_modules/tslib/tslib.js:136:27)
    at Object.next (/var/user/node_modules/tslib/tslib.js:117:57)
    at fulfilled (/var/user/node_modules/tslib/tslib.js:107:62)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:188:7); at cloud.callFunction api;


最后一次编辑于  星期三 17:14
回答关注问题邀请回答
收藏
问题标签