首页 > 解决方案 > 在本机反应上获取错误网络但在邮递员上工作

问题描述

我目前正在开发一个 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))

标签: react-nativeherokufetchpostman

解决方案


推荐阅读