错误信息:
函数调用失败 {code: “OPERATION_FAIL”, msg: “[INVALID_PARAM] [100004] Env do not have datakey”}
index.ts:35 请确认以下各项:
index.ts:35 1 - 调用 callFunction() 的语法或参数是否正确
index.ts:35 2 - 当前环境下是否存在此函数
index.ts:35 3 - 函数安全规则是否限制了当前登录状态访问
WASubContext.js?t=wechat&s=1647653685777&v=2.23.1:2 Unhandled promise rejection Error
at Cloudbase.callFunction (index.ts:35)
at VueComponent.validStart (index.vue:38)
at index.ts:35
at Array.forEach (<anonymous>)(env: macOS,mp,1.05.2201240; lib: 2.23.1)
****
搜索不到关于以上错误信息的解答
云函数通过云测试能够正常调用
我是用uni-app开发,调用方式如下:
main.js中
// 引入 & 初始化 cloudbase
import cloudbase from '[@cloudbase](/user/cloudbase)/js-sdk'
import adapter from '../uni_app/adapter.js'
cloudbase.useAdapters(adapter);
cloudbase.init({
env: 'mindct-****',
appSign: 'wx****',
appSecret: {
appAccessKeyId: 1,
appAccessKey: '****'
}
})
Vue.config.productionTip = false
App.mpType = 'app'
const app = new Vue({
...App
});
app.$mount();
vue中调用脚本如下:
<script>
import cloudbase from "[@cloudbase](/user/cloudbase)/js-sdk";
export default {
data() {
return {
// 省略
};
},
methods: {
validStart() {
let startTime = new Date();
uni.showLoading();
cloudbase
.callFunction({
name: "userinfo",
data: {
type: "validate",
mobile: this.validMobile,
},
})
.then((res) => { // 省略
});
let endTime = new Date();
uni.hideLoading();
console.log("click start at " + startTime + " end at " + endTime);
},
adminLogin() {
uni.navigateTo({
url: "/pagesB/login/login",
});
},
},
};
</script>