(ERROR: internal) Testing Firebase functions using React Native Expo

(ERROR: internal) Testing Firebase functions using React Native Expo

我正在尝试在我的 React Native Expo 应用程序中测试我的 firebase 函数。这是我的初始化代码:

import { connectFunctionsEmulator, getFunctions } from 'firebase/functions'

// ...Initialize app 

export const fucntions = getFunctions()
connectFunctionsEmulator(fucntions, "localhost", 5001)

然后我有了在对象中映射函数的代码:

import { httpsCallable } from "firebase/functions";
import { fucntions } from "../../firebase";

export default {
    helloFirebase: httpsCallable(fucntions, "helloFirebase")
}

我调用函数如下:

functionsObj.helloFirebase({ myParam: "Hello!" })
    .then((res) => {
        console.log(res)
    })
    .catch((error) => {
        console.log(error.message)
    })

但是当我调用该函数时,我在控制台中收到以下非常小且不明确的错误消息:

ERROR: internal

我猜这与无法访问本地主机有关,但我仍然不知道如何解决这个问题。

任何帮助将不胜感激,谢谢!

已修复:我在 this 确切问题上找到了这篇文章。

确保在完成所有步骤后运行firebase serve --only functions -o ${YOUR_LOCAL_IP}