当前位置 : 主页 > 网页制作 > React >

react-native – 响应本机提取而不发送正文内容

来源:互联网 收集:自由互联 发布时间:2021-06-15
我是新来的反应原生,并遵循 this tutorial. 我正在尝试将json主体发送到私有api服务器,我检查了服务器日志,发现正文内容为空. 这是反应原生的代码 authenticateLogIn(){ fetch('URL', { method: 'POST
我是新来的反应原生,并遵循 this tutorial.
我正在尝试将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();
也许是因为它被称为标题? (与s)
网友评论