
result代表服务器响应的所有数据,包含了响应头和响应体。result.data代表的是接口响应的核心数据

html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
<script>
// axios({
// method:'get',
// url:'http://localhost:8080/article/getAll'
// }).then((result) => {
// console.log(result.data);
// }).catch((err) => {
// });
axios.get('http://localhost:8080/article/getAll').then((result) => {
console.log(result.data);
}).catch((err) => {
console.log(err);
});
let article={
title:'明天会更哈',
category:'生活',
time:'2000-01-01',
state:'草稿'
};
// axios({
// method:'post',
// url:'http://localhost:8080/article/add',
// data:article
// }).then((result) => {
// console.log(result.data);
// }).catch((err) => {
// console.log(err);
// });
// axios.post('http://localhost:8080/article/add', 'id=1').then((result) => {
// console.log(result.data);
// }).catch((err) => {
// console.log(err);
// });
</script>
</body>
</html>