admin管理员组文章数量:1414605
I have a react native app with react-native-firebase and I'm trying to run a callable https firebase function which is deployed to a custom region.
I've read that firebase.app().functions("MY-REGION")
so I tried the following:
import { firebase } from "@react-native-firebase/database"
import functions from "@react-native-firebase/functions"
firebase.app().functions("MY-REGION")
But If I run that I get this error:
Error: You attempted to use
"firebase.app('[DEFAULT]').functions" but this
module could not be found.
Ensure you have installed and imported the
'@react-native-firebase/functions' package
The functions package is installed.
If I remove the @react-native-firebase/functions
import the error stays the same.
How can I specify the region for firebase https functions in react-native-firebase
?
More attempts:
firebase.initializeApp({
...options
})
firebase.app().functions("MY-REGION")
And that says Error: Firebase App named '[DEFAULT]' already exists
firebase.initializeApp({
...options
}, "APP_NAME")
firebase.app("APP_NAME").functions("MY-REGION")
Gives Error: No firebase App 'APP_NAME' has been created - call firebase.initializeApp()
I hope I'm missing something trivial.
I have a react native app with react-native-firebase and I'm trying to run a callable https firebase function which is deployed to a custom region.
I've read that firebase.app().functions("MY-REGION")
so I tried the following:
import { firebase } from "@react-native-firebase/database"
import functions from "@react-native-firebase/functions"
firebase.app().functions("MY-REGION")
But If I run that I get this error:
Error: You attempted to use
"firebase.app('[DEFAULT]').functions" but this
module could not be found.
Ensure you have installed and imported the
'@react-native-firebase/functions' package
The functions package is installed.
If I remove the @react-native-firebase/functions
import the error stays the same.
How can I specify the region for firebase https functions in react-native-firebase
?
More attempts:
firebase.initializeApp({
...options
})
firebase.app().functions("MY-REGION")
And that says Error: Firebase App named '[DEFAULT]' already exists
firebase.initializeApp({
...options
}, "APP_NAME")
firebase.app("APP_NAME").functions("MY-REGION")
Gives Error: No firebase App 'APP_NAME' has been created - call firebase.initializeApp()
I hope I'm missing something trivial.
Share Improve this question edited Jun 13, 2020 at 20:43 Frank van Puffelen 601k85 gold badges890 silver badges860 bronze badges asked Jun 13, 2020 at 20:31 GuglieGuglie 2,4712 gold badges29 silver badges51 bronze badges1 Answer
Reset to default 10A solution is to change the functions import from import functions from "..."
to import "..."
:
import { firebase } from "@react-native-firebase/database"
import "@react-native-firebase/functions" // <--
// call a https firebase function
firebase.app().functions("MY-REGION").httpsCallable('MyFunction')()
Note that MY-REGION
should be set to the region shown in the firebase functions dashboard for the selected httpsCallable function.
The fix I found was indeed quite trivial...
I've shared it here so it can be useful for others, but better solutions are wele!
本文标签: javascriptHow to set functions region for React Native FirebaseStack Overflow
版权声明:本文标题:javascript - How to set functions region for React Native Firebase - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745195114a2647098.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论