与axios响应本机请求

时间:2019-06-16 21:09:25

标签: node.js react-native asynchronous axios genymotion

我正在尝试向我的nodeJS后端API发出axios请求。 我正在将Genymotion与请求设置结合使用:

async componentDidMount() {
            const response = await axios.get('http://10.0.3.2:3333/posts');

            console.log(response)
    }

我得到这个作为回应: Request response

但是我希望得到真实的数据,就像我在浏览器中发出get请求时一样: enter image description here

所以我只能在其他域的请求上遇到问题

数据字符串: enter image description here

这是mais入口点控制器:

Routes.js
routes.get('/posts', postController.index);

postController.index

async index(req, res) {
        console.log(req)
        const post = await Post.find().sort('-createdAt')
        return res.json(post)
    }

请求未到达控制台。

1 个答案:

答案 0 :(得分:0)

我已经使用自己的IP地址解决了这个问题,我复制了IPV6地址并将其用作发出请求的地址。

相关问题