Fetch

作者: IT匠心说 | 来源:发表于2021-05-19 10:41 被阅读0次
  • POST / JSON

let data = {
  name: 'zhangsan',
  age: 23
};

fetch('http://localhost:8080/hello',{
  method:'POST',
    headers:{
        'Content-Type': 'application/json;charset=UTF-8',
        'Token': null
    },
    body: JSON.stringify(data),
})
.then(res =>res.json())
.then((json) => {

    console.log(json);

    let {code, msg, data} = json;
    if(code != 'ok') {
        message.info(msg);
        return;
    }

    // ...

});

相关文章

网友评论

      本文标题:Fetch

      本文链接:https://www.haomeiwen.com/subject/qhxpjltx.html