小程序云函数调用报错

作者: black_wizard 分类: 微信 发布时间: 2019-03-26 17:06

使用 cloud.callFunction({ name: ‘XXX’ } 时,调用失败,提示如下错误

{“errorCode”:1,”errorMessage”:”user code exception caught”,”stackTrace”:”errCode: -504002 functions execute fail | errMsg: callFunction:fail requestID undefined, Function not found: [getConf]; at callFunction api; “}


找不到指定的函数 getConf ,

在当前环境中核对检查云函数,确定 getConf 已经上传到当前环境并部署。。。

原因: 在云开发新建了环境B
虽然开发工具上 cloudfunctions|环境B 已经切换,但是cloud.init() 使用的是默认环境,依旧指向原环境,需要在
cloudfunctions 下的云函数的index.js文件中 重新配置

cloudcloud.init({ env: ‘ 环境B的id ‘})