react-native - 在本机反应上获取错误网络但在邮递员上工作
问题描述
我目前正在开发一个 react-native 应用程序。在登录部分工作时,我成功地以正确的返回调用邮递员,但是当通过 react-native android 客户端获取时,调用 heroku 服务器时我绝对没有返回,甚至在本地运行服务器时出现网络故障错误。
我究竟做错了什么 ?我绝对没有从下面的代码中得到任何日志。
const payloadJson = JSON.stringify({
email: 'julien@hypecode.com',
password: 'password',
})
fetch('https://alsatoju-dev.herokuapp.com/login', {
method: 'POST',
body: payloadJson,
headers: {
Accept: '*/*',
'Content-Type': 'application/json',
},
}).then((response) => {
console.log(response)
return response.json()
})
.then((res) => console.log(res))
.catch((err) => console.log(err))
解决方案
推荐阅读
- c++ - 将 bazel 设置为环境变量 windows
- r - R Markdown:我的情节图正在被裁剪
- json - dotnet publish 不使用 appsettings.json
- reactjs - 如果条件为真,则在子组件中调用函数
- javascript - 你能在一个函数中拦截并创建一个 AxiosPromise 吗?
- java - 根据原始图像分辨率将图像大小调整为字节大小以下的算法
- java - android.widget.FrameLayout 无法转换为 androidx.appcompat.widget.Toolbar 错误
- php - 在 PHP 中,我可以为类属性设置别名吗?例如通过 Trait 允许 ArrayAccess 方法
- javascript - 在Javascript中将对象转换为数组
- microsoft-graph-api - 使用“@azure/msal-angularjs”:“^0.1.1”将 Graph API 工具包避免登录组件与通过 Azure AD 进行身份验证的现有应用程序集成