我是新来的反应本机,并遵循本教程.
我正在尝试将json主体发送到私有api服务器,我检查了服务器日志,发现正文内容为空.
这是反应原生的代码
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();
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2543 次 |
| 最近记录: |