我在使用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 ×1