【发布时间】:2018-08-28 03:27:25
【问题描述】:
我正在尝试注册,当我提交表单时,应用程序应显示服务返回的警报。这是服务的回报:
{
"Result": {
"retVal": "20404|Save Successed!"
}
}
获取代码如下:
fetch(url, {
method: 'POST',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',
},
body: JSON.stringify({ save:
{ NoKTP: '1234123412341234',
Nama: 'Rondi',
Email: 'rondi@rocketmail.com',
Password: '123qwert',
NoTelp: '779977',
NoHP: '081112222345' }
})
})
.then( (response) => response.json())
.then( (responseJson) => {
Alert.alert("respon : " + responseJson.retVal)
})
.catch((error) => {
console.error(error);
});
但是当我运行应用程序时,警报会显示我 “响应:未定义”
如何让 retVal 值显示在警报中? 有谁能够帮助我?提前谢谢..
【问题讨论】:
标签: json react-native fetch