Atu*_*ari 5 android ios reactjs react-native expo
InsertDataToServer = () => {
const { pinValue1 } = this.state;
const { pinValue2 } = this.state;
const { pinValue3 } = this.state;
const { pinValue4 } = this.state;
var String_3 = pinValue1.concat(" " , pinValue2);
var String_4 = String_3.concat(" " , pinValue3);
var String_5 = String_4.concat(" " , pinValue4);
fetch("http://www.aonde.biz/mobile/doLogin.php", {
method: "POST",
headers: {
Accept: "application/json",
"Content-Type": "application/json"
},
body: JSON.stringify({
"pin":212,
})
})
.then(response => response.json())
.then(responseJson => {
// Showing response message coming from server after inserting records.
Alert.alert(responseJson);
})
.catch(error => {
console.error(error);
});
Run Code Online (Sandbox Code Playgroud)
Bil*_*nko 20
当代码从以下位置更改时,此错误已修复:
Alert.alert('Error:', error)
到:
Alert.alert('Error:', error.message)
Nic*_*lva 11
在您的 Alert.alert(responseJson); 中,您需要将其字符串化,如下所示:
Alert.alert(JSON.stringify(responseJson));
Run Code Online (Sandbox Code Playgroud)
请记住,警报是移动应用程序的一个组件,因此它可能无法理解 JSON 内容中显示的代码。如果这不起作用,请使用responseJson.text()。
Sam*_*ara -3
您只需删除 中的双引号即可pin
。
fetch("http://www.aonde.biz/mobile/doLogin.php", {
method: "POST",
headers: {
Accept: "application/json",
"Content-Type": "application/json"
},
body: JSON.stringify({
pin:212,
})
})
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
21636 次 |
最近记录: |