简体   繁体   中英

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

I'm trying to test my firebase functions in my React Native Expo app. Here's my initialization code:

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

// ...Initialize app 

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

I then have code which maps functions in an object:

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

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

And I call the function as follows:

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

But when I call the function I get the following, very small and unspecific error message in the console:

ERROR: internal

I'm guessing it's something to do with not being able to access localhost, but I still don't know how to fix the issue.

Any help would be appreciated, thanks!

FIXED: I found this article on this exact issue.

Make sure to run firebase serve --only functions -o ${YOUR_LOCAL_IP} once you've followed all the steps

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM