{ retu-6ren">
gpt4 book ai didi

javascript - [Vue 警告] : Error in v-on handler: "TypeError: Object(...)(...).httpsCallable(...).then is not a function"

转载 作者:行者123 更新时间:2023-12-04 17:10:18 25 4
gpt4 key购买 nike

我正在尝试从我的 Vue 应用程序调用这个 firebase 云函数

exports.sayHi = functions.https.onCall((data, context) =>{
return "hi";
});

这是我在店里的 Action

import {
getFirebaseDB,
getFirebaseFunctions,
} from "../../helpers/firebase/authUtils";

reserveApt() {
getFirebaseFunctions()
.httpsCallable("sayHi")
.then((result) => {
console.log(result);
});
},

这是我在 ../../helpers/firebase/authUtils 中的辅助函数:

import firebase from "firebase/app";
import "firebase/auth";
import "firebase/firestore";
import "firebase/functions";

/**
* Initilize the backend
* @param {*} config
*/
const initFirebaseBackend = (config) => {
if (!_fireBaseBackend) {
_fireBaseBackend = new FirebaseAuthBackend(config);
_db = firebase.firestore();
_functions = firebase.functions();
}
return _fireBaseBackend;
};


/**
* Returns the firebase backend
*/
const getFirebaseBackend = () => {
return _fireBaseBackend;
};


/**
* returns firestore db
*/
const getFirebaseDB = () => {
if (!_db) {
_db = firebase.firestore();
}
return _db;
};


/**
* returns firebase functions
*/
const getFirebaseFunctions = () => {
if (!_functions) {
_functions = firebase.functions();
}
return _functions;
};


export {
initFirebaseBackend,
getFirebaseBackend,
getFirebaseDB,
getFirebaseFunctions,
};

Firebase 已正确初始化,所有其他功能(如 auth 和 firestore)都可以正常工作,但是当我调用它时出现此错误:

[Vue warn]: Error in v-on handler: "TypeError: Object(...)(...).httpsCallable(...).then is not a function"

found in

---> <Properties> at src/views/pages/property/properties.vue
<App> at src/App.vue
<Root>

最佳答案

显然问题出在调用函数上。我不得不这样调用它:

var reserve = getFirebaseFunctions().httpsCallable("sayHi");
reserve().then((result) => {
console.log(result);
});

但我不确定为什么!!

关于javascript - [Vue 警告] : Error in v-on handler: "TypeError: Object(...)(...).httpsCallable(...).then is not a function",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69601773/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com