小程序在云函数里面调用数据库不需要wx.cloud

当使用云函数报错时,要排查一下问题
1 是否在app.js中是否初始化云环境们是否设置了env环境id
在这里插入图片描述
2 是否在云函数中先初始化云环境再调用api
在这里插入图片描述
3 是否在云函数中使用了没有的module

Error: errCode: -404011 cloud function execution error | errMsg: cloud.callFunction:fail requestID 62024166-f8b0-11ea-af5e-525400742e8d, cloud function service error code -504002, error message ReferenceError: wx is not defined
!!!!注意这里wx is not defined,说明在云函数中没有wx这个moudules,
    at Object.<anonymous> (:43884/var/user/index.js:3)
    at Module._compile (:43884/appservice/internal/modules/cjs/loader.js:701)
    at Object.Module._extensions..js (:43884/appservice/internal/modules/cjs/loader.js:712)
    at Module.load (:43884/appservice/internal/modules/cjs/loader.js:600)
    at tryModuleLoad (:43884/appservice/internal/modules/cjs/loader.js:539)
    at Function.Module._load (:43884/appservice/internal/modules/cjs/loader.js:531)
    at Module.require (:43884/appservice/internal/modules/cjs/loader.js:637)
    at require (:43884/appservice/internal/modules/cjs/helpers.js:22)
    at Object.module.exports.load (:43884/var/runtime/node10/UserFunction.js:27)
    at Runtime.handleOnce (:43884/var/runtime/node10/Runtime.engine.js:95); at cloud.callFunction api; 
    at new u (VM24 WAService.js:2)
    at d (VM24 WAService.js:2)
    at f (VM24 WAService.js:2)
    at Function.success (VM24 WAService.js:2)
    at h (VM24 WAService.js:2)
    at VM24 WAService.js:2
    at A (VM24 WAService.js:2)
    at Function.<anonymous> (VM24 WAService.js:2)
    at h (VM24 WAService.js:2)
    at VM24 WAService.js:2
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值