This is my code:
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);
});
}
In the browser, this request returns a token, but in my react-native android App returns a xml error.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…