收藏
回答

云函数腾讯路线规划怎么调用?调用失败

const cloud = require('wx-server-sdk')
cloud.init()
const db = cloud.database()
var QQ = require('aaa.js');
var qqmama = new QQ({
  key'O3IBZ-WC7WJ-JTHFZ-FKFME-XUOSH-SFBSI' // 必填
});
exports.main = async (event, context) => {
  const countResult = await db.collection('zhuguan').where({
  }).get()
  for (let i = 0; i < countResult.data.length; i++) {
    qqmama.calculateDistance({
      mode'driving',//可选值:'driving'(驾车)、'walking'(步行),不填默认:'walking'
      from:  '30.878231,120.139122',
      to'23.694044,113.134750'//若起点有数据则采用起点坐标,若为空默认当前地址
      successfunction(res{//成功后的回调
      },
   });
  }
}

日志{"msg":"ERROR RequestId:499d4337-2f94-11eb-aa44-525400ff21a1 Result:{\"errCode\":1,\"errMsg\":\"user code exception caught\",\"stackTrace\":\"ReferenceError: wx is not defined\\n    at locationsuccess (/var/user/aaa.js:1016:13)\\n    at Object.locationProcess (/var/user/aaa.js:650:13)\\n    at QQMapWX.calculateDistance (/var/user/aaa.js:1022:17)\\n    at Runtime.exports.main [as handler] (/var/user/index.js:15:28)\\n    at process._tickCallback (internal/process/next_tick.js:68:7)\"}","level":"error","src":"app","requestId":"499d4337-2f94-11eb-aa44-525400ff21a1","function":"xc","timestamp":"1606359950353721"}
最后一次编辑于  2020-11-26
回答关注问题邀请回答
收藏

1 个回答

登录 后发表内容
问题标签