微信小程序云函数请求失败

请求错误 Error: cloud.callFunction:fail Error: errCode: -504002 functions execute fail | errMsg: Error: errCode: -501003 exceed request limit | errMsg: [LimitExceeded.OutOfReadRequestQuota] Read overrun. Please improve read specifications, but if the problem cannot be solved, contact us.; 
    at Object.returnAsCloudSDKError (:31206/var/user/node_modules/wx-server-sdk/index.js:6675)
    at Object.checkError (:31206/var/user/node_modules/wx-server-sdk/index.js:1364)
    at :31206/var/user/node_modules/wx-server-sdk/index.js:1430
    at processTicksAndRejections (:31206/appservice/internal/process/task_queues.js:97) (callId: 1700837942966-0.03024751371625123) (trace: 22:59:2 start->22:59:3 system error (Error: errCode: -504002 functions execute fail | errMsg: Error: errCode: -501003 exceed request limit | errMsg: [LimitExceeded.OutOfReadRequestQuota] Read overrun. Please improve read specifications, but if the problem cannot be solved, contact us.; 
    at Object.returnAsCloudSDKError (:31206/var/user/node_modules/wx-server-sdk/index.js:6675)
    at Object.checkError (:31206/var/user/node_modules/wx-server-sdk/index.js:1364)
    at :31206/var/user/node_modules/wx-server-sdk/index.js:1430
    at processTicksAndRejections (:31206/appservice/internal/process/task_queues.js:97)), abort)
    at ar (VM1526 WAService.js:2)
    at VM1526 WAService.js:2
    at VM1526 WAService.js:2
    at n (VM1526 WAService.js:2)

云函数:

// 云函数模板
// 部署:在 cloud-functions/login 文件夹右击选择 “上传并部署”

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

// 初始化 cloud
cloud.init({
  // // API 调用都保持和云函数当前所在环境一致
  // env: cloud.DYNAMIC_CURRENT_ENV
})

const db = cloud.database()
var _id = ''

/**
 * 这个示例将经自动鉴权过的小程序用户 openid 返回给小程序端
 * 
 * event 参数包含小程序端调用传入的 data
 * 
 */
exports.main = async (event, context) => {
  
  
  let _id =  await db.collection('all_user_table').where({
    username:event.username,
    password:event.password
  }).get({
    success:function(res){ 
    }
  })
  let data = await panduan(_id)
  // return _id.data[0]._id
  return data
  
}

function panduan(_id){
  var user_id = ""
  var face_image_url = "xx"
  var data = {}
  return new Promise((resolve,reject)=>{
    success:{
      if(Object.keys(_id.data).length==0){
        user_id = ""
        face_image_url = ""
        data = {user_id, face_image_url}
        // resolve(data)
      }else if(Object.keys(_id.data).length==1){
        user_id = _id.data[0]._id
        face_image_url = _id.data[0].face_image_url
        data = {user_id, face_image_url}
        // resolve(data)
      }else{
        user_id = "错误,查找到多个值"
        face_image_url = ""
        data = {user_id, face_image_url}
        // resolve(data)
      }
      resolve(data)
    }
    
    
  })

}

该云函数要请求云数据库。

然而:

微信小程序云函数请求失败_第1张图片

数据库请求已经超了,也就是不能访问云数据库了.......

试一下不用访问云数据库的云函数:

// 云函数入口文件
const cloud = require('wx-server-sdk')
cloud.init()

// 云函数入口函数
exports.main = async (event, context) => {
let a=event.a;
let b=event.b;
return a+b;
}

微信小程序云函数请求失败_第2张图片

可以成功执行。

你可能感兴趣的:(微信小程序,小程序)