当使用fetch-in-react-native进行API调用时,不会触发Firebase函数

当使用fetch-in-react-native进行API调用时,不会触发Firebase函数,firebase,react-native,google-cloud-functions,Firebase,React Native,Google Cloud Functions,我有一个firebase函数,可以在localhots端口5001上本地运行,我有一些函数在直接从浏览器调用它时可以工作,但是当我从应用程序调用它时,什么都没有发生 下面是我运行调用时使用的服务器时给出的路径:http://localhost:5001/newApp/us-central1/ 以下是前端的代码: const onCreateSetupIntent = async () => { setLoading(true) try {

我有一个firebase函数,可以在
localhots
端口
5001
上本地运行,我有一些函数在直接从浏览器调用它时可以工作,但是当我从应用程序调用它时,什么都没有发生 下面是我运行调用时使用的服务器时给出的路径:
http://localhost:5001/newApp/us-central1/
以下是前端的代码:

  const onCreateSetupIntent = async () => {


          setLoading(true)
            try {
                fetch('http://localhost:5001/newApp/us-central1/stripeKey')
                    .then((response) => response.json())
                    .then((res) => {
                        console.log(res)
                        setLoading(false)
                        setSetupIntent(res)
                    })
               
    
            } catch (e) {
                console.log("error:", e)
                 setLoading(false)
            }
    
        }
我在android设备上运行这个应用程序,我读到在android中我必须将URL中的localhost更改为我的计算机IP,我也这样做了,但仍然无法工作

我已经检查了端点和请求方法是否都匹配,没有问题

还有一件事,在我按上面提到的按钮发出请求后,服务器端没有发生任何事件,也没有日志,然后出现以下错误:

 Possible Unhandled Promise Rejection (id: 0):
TypeError: Network request failed

这可能是防火墙问题,请尝试禁用主机防火墙,然后重试