Fetch

2021-05-19  本文已影响0人  IT匠心说

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;
    }

    // ...

});
上一篇下一篇

猜你喜欢

热点阅读