【发布时间】:2016-12-20 13:29:08
【问题描述】:
我是新来的 react native 并关注 this tutorial。
我正在尝试将json正文发送到私有api服务器,我检查了服务器日志,发现正文内容为空。
这是 react native 中的代码
authenticateLogIn(){
fetch('<URL>', {
method: 'POST',
header: {'Content-Type': 'application/json', 'Accept': 'application/json'},
body: JSON.stringify({'username': '<username>', 'password':'<password>'})
})
.then((incoming) => incoming.json())
.then((response) => {
console.log(response.header);
Alert.alert(JSON.stringify(response.body));
})
.done();
【问题讨论】:
标签: react-native