从真实设备调用本地 api 失败(反应原生安卓)


signinFetch('http://192.xxx.x.x:8000/api/branch-api/login', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    grant_type: 'password',
    client_id: OAUTH_CLIENT_ID,
    client_secret: OAUTH_CLIENT_SECRECT,
    email: this.props.email,
    password: this.props.password,
    scope: ''
  })
})
.then((response) => {
  console.log(response);
})
.catch((error) => {
   console.log(error);
});

无法从物理设备调用登录 API 到本地主机。但是我可以在本地主机上调试应用程序,那为什么我没有得到本地 api 的响应

我试过了

这里有一个谷歌文档可以将本地主机连接到物理设备。参考这个,它简单易行

最新更新