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',
from: '30.878231,120.139122',
to: '23.694044,113.134750',
success: function(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"}
失败的日志发一下,看看什么情况