我正在使用Expo构建一个React Native应用程序,我试图像这样获取我的后端服务器:
useEffect(() => {
fetch('http://192.168.1.89:8080/api/ciborg/groups')
.then((response) => response.json())
.then((json) => setData(json))
.catch((error) => console.log("->>>>"+error))
.finally(() => setLoading(false));
});
字符串
但它总是给我以下错误
“TypeError:无法获取”。
我已经尝试了以下操作:
fetch('http://192.168.1.89:8080/api/ciborg/groups')
fetch('http://localhost:8080/api/ciborg/groups')
fetch('http://127.0.0.1:8080/api/ciborg/groups')
型
但结果总是一样的。但是,获取外部API,例如:https://reactnative.dev/movies.json工作。
有人能帮忙吗?
1条答案
按热度按时间4nkexdtk1#
NodeJS Express服务器我还补充道:
字符串
它解决了我的问题。