- 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;
}
// ...
});
网友评论