57 lines
1.2 KiB
HTML
57 lines
1.2 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Document</title>
|
|
</head>
|
|
|
|
<body>
|
|
|
|
</body>
|
|
<script src="./http.js"></script>
|
|
<script>
|
|
// callback 获取异步返回值
|
|
// 回调地狱
|
|
|
|
// promise
|
|
|
|
let getIndex = async () => {
|
|
// TODO 后期项目中封装
|
|
// let res = await http.post({ id: 1, page: 1 });
|
|
let res = await http.post({
|
|
url: 'http://127.0.0.1:3000/api/json/index',
|
|
headers: {
|
|
'token': 'hahhaha'
|
|
},
|
|
data: {
|
|
id: 1,
|
|
page: 1
|
|
}
|
|
});
|
|
console.log(res);
|
|
}
|
|
|
|
getIndex()
|
|
|
|
// http.post({
|
|
// url: 'http://127.0.0.1:3000/api/json/index',
|
|
// headers: {
|
|
// 'token': 'hahhaha'
|
|
// },
|
|
// data: {
|
|
// id: 1,
|
|
// page: 1
|
|
// }
|
|
// })
|
|
// .then(res => {
|
|
// console.log(res);
|
|
// })
|
|
// .catch(err => {
|
|
// console.log(err);
|
|
// })
|
|
</script>
|
|
|
|
</html> |