相关疑难解决方法(0)

React Native - 获取POST请求作为GET请求发送

我在使用FETCH时遇到问题.

我试图在react-native中使用FETCH发出POST请求.

    fetch("http://www.example.co.uk/login", {
        method: 'POST',
        headers: {
            'Accept': 'application/json',
            'Content-Type': 'application/json'
        },
        body: JSON.stringify({
            username: 'test',
            password: 'test123',
        })
    })

        .then((response) => response.json())
        .then((responseData) => {
            console.log(
                "POST Response",
                "Response Body -> " + JSON.stringify(responseData)
            )
        })
        .done();
}
Run Code Online (Sandbox Code Playgroud)

当我使用Charles检查此调用时,它被记录为GET请求,并且不存在应该在正文中的用户名和密码.

在此输入图像描述

有人可以帮忙解决这个问题吗?

react-native

11
推荐指数
4
解决办法
4万
查看次数

标签 统计

react-native ×1