【发布时间】:2019-07-25 00:06:12
【问题描述】:
我正在使用带有 Expo 和 ASP.Net Web API 的 React Native 构建一个应用程序。
我正在使用两台计算机:一台我在其上发布了 Web API,并将其用作具有 IP 192.168.1.9 的服务器,
另一个我用于开发的IP 192.168.1.6。
问题是,当我 ping 服务器计算机时,我得到了回复,当我使用邮递员时,我得到了我请求的数据,
但是当我在我的 Android 手机上使用 Expo 运行应用程序时,请求会进入 catch 并返回错误。 代码如下:
var url = 'http://192.168.1.9/trainlast/api/Login';
fetch(url,
{
method: 'GET',
})
.then(response => { response.json(); })
.then(users => {
this.setState({ allUsers: users });
})
.catch(error => console.error('Error getting users :: ', error));
我已经尝试了我能想到的一切,但没有用。
谁能告诉我问题出在哪里?谢谢。
【问题讨论】:
标签: react-native asp.net-web-api expo