【发布时间】:2017-02-02 19:49:51
【问题描述】:
这是我的代码:
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 App 中返回一个 xml 错误。
【问题讨论】:
标签: javascript react-native post request