这是我的代码:
componentWillMount() {
fetch("http://localmachine/localservice/webservice/rest/server.php", {
method: 'POST',
body: JSON.stringify({
wstoken: 'any_token',
wsfunction: 'any_function',
moodlewsrestformat: 'json',
username: 'user',
password: 'pass',
})
})
.then((response) => response.text())
.then((responseText) => {
alert(responseText);
})
.catch((error) => {
console.error(error);
});
}
在浏览器中,此请求返回一个令牌,但在我的react-native android应用程序中,返回一个xml错误.